onadata.apps.logger.tests package

Subpackages

Submodules

onadata.apps.logger.tests.test_backup_tools module

class onadata.apps.logger.tests.test_backup_tools.TestBackupTools(methodName='runTest')

Bases: TestBase

setUp()

Hook method for setting up the test fixture before exercising it.

test_backup_then_restore_from_zip()
test_date_created_from_filename()
test_date_created_override()

Test that passing a date_created_override when creating and instance will set our date as the date_created

onadata.apps.logger.tests.test_briefcase_api module

onadata.apps.logger.tests.test_briefcase_client module

onadata.apps.logger.tests.test_customize_template_by_domain module

class onadata.apps.logger.tests.test_customize_template_by_domain.TestCustomizeTemplateTasks(methodName='runTest')

Bases: TestBase

Test api tasks

test_for_domain()

Test settings_value returns correct values

test_for_no_domain()

Test settings_value returns correct values

test_for_no_domain_no_settings()

Test settings_value returns correct values

onadata.apps.logger.tests.test_digest_authentication module

class onadata.apps.logger.tests.test_digest_authentication.TestDigestAuthentication(methodName='runTest')

Bases: TestBase

setUp()

Hook method for setting up the test fixture before exercising it.

test_authenticated_submissions()

xml_submission_file is the field name for the posted xml file.

test_digest_authentication_with_odk_token_storage()

Test that a valid Digest request with as the auth email:odk_token is authenticated

test_fail_authenticated_submissions_to_wrong_account()
test_fails_authentication_past_odk_token_expiry()

Test that a Digest authenticated request using an ODK Token that has expired is not authorized

onadata.apps.logger.tests.test_encrypted_submissions module

Test encrypted form submissions.

class onadata.apps.logger.tests.test_encrypted_submissions.TestEncryptedForms(methodName='runTest')

Bases: TestBase

TestEncryptedForms test class.

setUp()

Hook method for setting up the test fixture before exercising it.

test_encrypted_multiple_files()

Test missing encrytped files has all_media_received=False.

test_encrypted_submissions()

Test encrypted submissions.

onadata.apps.logger.tests.test_form_list module

class onadata.apps.logger.tests.test_form_list.TestFormList(methodName='runTest')

Bases: TestBase

setUp()

Hook method for setting up the test fixture before exercising it.

test_return_401_for_anon_when_require_auth_true()
test_returns_200_for_authenticated_non_owner()
test_returns_200_for_owner()
test_show_for_anon_when_require_auth_false()

onadata.apps.logger.tests.test_form_submission module

Test data submissions.

class onadata.apps.logger.tests.test_form_submission.TestFormSubmission(methodName='runTest')

Bases: TestBase

Testing POSTs to “/submission”

setUp()

Hook method for setting up the test fixture before exercising it.

test_duplicate_form_id()

Should return an error if submitting to a form with a duplicate ID.

test_duplicate_submission_with_different_content()

Test xml submissions with same instancID but different content

test_duplicate_submission_with_same_instanceid()

Test duplicate xml submissions

test_duplicate_submissions()

Test submissions for forms with start and end

test_edit_updated_geopoint_cache()
test_edited_submission()

Test submissions that have been edited

test_edited_submission_require_auth()

Test submissions that have been edited

test_fail_submission_if_bad_id_string()

Test that a submission fails if the uuid’s don’t match.

test_fail_with_ioerror_read(mock_pop)
test_fail_with_ioerror_wsgi(mock_pop)
test_fail_with_unreadable_post_error(mock_create_instance)

Test UnreadablePostError is handled on form data submission

test_form_post()

xml_submission_file is the field name for the posted xml file.

test_form_post_to_missing_form()
test_form_submission_with_infinity_values()

When using a calculate field in XLSForm the result may be an infinity value which would not be valid for a Postgres json field. This would result in a DataError exception being thrown by Django. Postgres Error would be Invalid Token Infinity

This test confirms that we are handling such cases and they do not result in 500 response codes.

test_post_save_submission_count_update(mock)

Test that submission count is updated asyncronously

test_submission_linked_to_reporter()
test_submission_to_require_auth_anon()

Test submission to private form by non-owner without perm is forbidden

test_submission_to_require_auth_without_perm()

Test submission to private form by non-owner without perm is forbidden

test_submission_w_mismatched_uuid()

test allowing submissions where xml’s form uuid doesnt match any form’s uuid for a user, as long as id_string can be matched

test_submission_when_requires_auth()
test_unicode_submission()

Test xml submissions that contain unicode characters

onadata.apps.logger.tests.test_form_submission.catch_signal(signal)

onadata.apps.logger.tests.test_importing_database module

class onadata.apps.logger.tests.test_importing_database.TestImportingDatabase(methodName='runTest')

Bases: TestBase

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_badzipfile_import()
test_bulk_import_post()
test_bulk_import_post_with_username_in_uppercase()
test_importing_b1_and_b2()

b1 and b2 are from the same phone at different times. (this might not be a realistic test)

b1: 1 photo survey (completed) 1 simple survey (not marked complete)

b2: 1 photo survey (duplicate, completed) 1 simple survey (marked as complete)

onadata.apps.logger.tests.test_importing_database.images_count(username='bob')

onadata.apps.logger.tests.test_instance_creation module

class onadata.apps.logger.tests.test_instance_creation.TestInstanceCreation(methodName='runTest')

Bases: TestCase

setUp()

Hook method for setting up the test fixture before exercising it.

test_data_submission()
test_form_submission()
test_submission_for_missing_form()
onadata.apps.logger.tests.test_instance_creation.create_post_data(path)
onadata.apps.logger.tests.test_instance_creation.get_absolute_path(subdirectory)
onadata.apps.logger.tests.test_instance_creation.open_all_files(path)

onadata.apps.logger.tests.test_parsing module

class onadata.apps.logger.tests.test_parsing.TestXFormInstanceParser(methodName='runTest')

Bases: TestBase

test_get_deprecated_uuid_from_xml()
test_get_meta_from_xml()
test_get_meta_from_xml_without_uuid_returns_none()
test_get_uuid_from_xml()
test_multiple_media_files_on_encrypted_form()
test_parse_xform_nested_repeats()
test_parse_xform_nested_repeats_multiple_nodes()
test_xml_repeated_nodes_to_dict()
test_xpath_from_xml_node()

onadata.apps.logger.tests.test_publish_xls module

class onadata.apps.logger.tests.test_publish_xls.TestPublishXLS(methodName='runTest')

Bases: TestBase

test_publish_xls()
test_publish_xls_replacement()
test_publish_xls_version()
test_report_exception_with_exc_info()
test_report_exception_without_exc_info()
test_single_entity_allowed_per_form()
test_xform_big_image_invalid_if_no_image()
test_xform_hash()

onadata.apps.logger.tests.test_simple_submission module

class onadata.apps.logger.tests.test_simple_submission.TempFileProxy(content)

Bases: object

create_instance will be looking for a file object, with “read” and “close” methods.

close()
read()
class onadata.apps.logger.tests.test_simple_submission.TestSimpleSubmission(methodName='runTest')

Bases: TestCase

setUp()

Hook method for setting up the test fixture before exercising it.

test_corrupted_submission()

Test xml submissions that contain unicode characters.

test_simple_yes_submission()
test_start_time_boolean_properly_set()
test_start_time_submissions()

This test checks to make sure that instances with start_time available are marked as duplicates when the XML is a direct match.

onadata.apps.logger.tests.test_tasks module

Tests for module onadata.apps.logger.tasks

class onadata.apps.logger.tests.test_tasks.CommitEListNumEntitiesAsyncTestCase(methodName='runTest')

Bases: TestBase

Tests for method commit_cached_elist_num_entities_async

setUp()

Hook method for setting up the test fixture before exercising it.

test_counter_commited(mock_commit)

Cached counter is commited in the database

test_retry_connection_error(mock_retry, mock_set_perms)

ConnectionError exception is retried

test_retry_database_error(mock_retry, mock_set_perms)

DatabaseError exception is retried

class onadata.apps.logger.tests.test_tasks.SetEntityListPermsAsyncTestCase(methodName='runTest')

Bases: TestBase

Tests for set_entity_list_perms_async

setUp()

Hook method for setting up the test fixture before exercising it.

test_invalid_pk(mock_logger, mock_set_perms)

Invalid EntityList primary key is handled

test_retry_connection_error(mock_retry, mock_set_perms)

ConnectionError exception is retried

test_retry_database_error(mock_retry, mock_set_perms)

DatabaseError exception is retried

test_set_perms(mock_set_perms)

Permissions are applied

class onadata.apps.logger.tests.test_tasks.UpdateProjectDateModified(methodName='runTest')

Bases: TestBase

Tests for apply_project_date_modified_async

setUp()

Hook method for setting up the test fixture before exercising it.

test_update_project_date_modified()

Test project date_modified field is updated

test_update_project_date_modified_empty_cache()

Test project date modified empty cache

onadata.apps.logger.tests.test_transfer_project_command module

Tests for project transfer command

class onadata.apps.logger.tests.test_transfer_project_command.TestMoveProjectToAnewOwner(methodName='runTest')

Bases: TestBase

test_single_project_transfer()

“Test for a successful project transfer.

test_successful_project_transfer()

“Test for a successful project transfer.

test_xforms_are_transferred_as_well()

Test the transfer of ownership of the XForms.

class onadata.apps.logger.tests.test_transfer_project_command.TestUserValidation(methodName='runTest')

Bases: TestBase

Created this class to specifically test for the user validation.

When the function is put together with the other test functions above, it’s stdout is interfering with the other functions causing them to fail. stdout.flush() does not help.

test_user_given_does_not_exist()

Test that users are validated before initiating project transfer

onadata.apps.logger.tests.test_update_xform_uuid module

class onadata.apps.logger.tests.test_update_xform_uuid.TestUpdateXFormUUID(methodName='runTest')

Bases: TestBase

setUp()

Hook method for setting up the test fixture before exercising it.

test_fail_update_on_duplicate_uuid()
test_update_xform_uuid()

onadata.apps.logger.tests.test_webforms module

Module contents