onadata.apps.logger.tests package¶
Subpackages¶
- onadata.apps.logger.tests.management package
- onadata.apps.logger.tests.models package
- Submodules
- onadata.apps.logger.tests.models.test_attachment module
TestAttachmentTestAttachment.setUp()TestAttachment.test_create_attachment_with_media_file_length_more_the_100()TestAttachment.test_create_attachment_with_mimetype_more_than_50()TestAttachment.test_create_thumbnails_command()TestAttachment.test_get_original_filename()TestAttachment.test_mimetype()TestAttachment.test_thumbnails()TestAttachment.test_upload_to()
- onadata.apps.logger.tests.models.test_data_view module
- onadata.apps.logger.tests.models.test_entity module
- onadata.apps.logger.tests.models.test_entity_list module
EntityListTestCaseEntityListTestCase.setUp()EntityListTestCase.test_creation()EntityListTestCase.test_defaults()EntityListTestCase.test_hard_delete()EntityListTestCase.test_max_name_length()EntityListTestCase.test_name_project_unique_together()EntityListTestCase.test_permissions_applied_async()EntityListTestCase.test_properties()EntityListTestCase.test_soft_delete()
- onadata.apps.logger.tests.models.test_follow_up_form module
- onadata.apps.logger.tests.models.test_instance module
TestInstanceTestInstance.setUp()TestInstance.test_create_entity()TestInstance.test_create_entity_exists()TestInstance.test_create_entity_false()TestInstance.test_create_entity_true()TestInstance.test_decrypt_instance_managed_encryption()TestInstance.test_decrypt_instance_unmanaged_encryption()TestInstance.test_entity_create_update_true()TestInstance.test_get_id_string_from_xml_str()TestInstance.test_hard_delete_xform_num_of_decrypted_submissions_decremented()TestInstance.test_instance_json_updated_on_review()TestInstance.test_instances_with_geopoints_in_repeats()TestInstance.test_instances_with_malformed_geopoints_dont_trigger_value_error()TestInstance.test_json_stores_user_attribute()TestInstance.test_light_tasks_synchronous()TestInstance.test_numeric_checker_with_negative_integer_values()TestInstance.test_parse_numbers()TestInstance.test_query_data_sort()TestInstance.test_query_filter_by_datetime_field()TestInstance.test_query_filter_by_integer()TestInstance.test_registration_form_inactive()TestInstance.test_retrieve_non_existent_submission_review()TestInstance.test_set_instances_with_geopoints_on_submission_false()TestInstance.test_set_instances_with_geopoints_on_submission_true()TestInstance.test_set_is_encrypted()TestInstance.test_soft_delete_xform_num_of_decrypted_submissions_decremented()TestInstance.test_stores_json()TestInstance.test_submission_review_enabled_entity_create()TestInstance.test_submission_review_enabled_entity_update()TestInstance.test_update_entity()TestInstance.test_update_entity_false()TestInstance.test_update_entity_label()TestInstance.test_update_entity_true()TestInstance.test_update_entity_via_instance_update()TestInstance.test_updates_json_date_modified_on_save()TestInstance.test_xml_entity_node_missing()
- onadata.apps.logger.tests.models.test_note module
- onadata.apps.logger.tests.models.test_project_invitation module
- onadata.apps.logger.tests.models.test_registration_form module
- onadata.apps.logger.tests.models.test_submission_review module
- onadata.apps.logger.tests.models.test_xform module
TestXFormTestXForm.test_check_xform_uuid()TestXForm.test_get_media_survey_xpaths()TestXForm.test_get_survey_element()TestXForm.test_get_survey_from_file_object_file_pointer_reset()TestXForm.test_id_string_length()TestXForm.test_id_string_max_length_on_soft_delete()TestXForm.test_live_num_of_decrypted_submissions()TestXForm.test_multiple_model_nodes()TestXForm.test_num_of_pending_decryption_submissions()TestXForm.test_restore_deleted()TestXForm.test_restore_deleted_merged_xform()TestXForm.test_set_title_unicode_error()TestXForm.test_soft_delete()TestXForm.test_submission_count()TestXForm.test_update_num_of_decrypted_submissions()TestXForm.test_version_length()
- Module contents
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:
TestBaseTest 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:
TestBaseTestEncryptedForms 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.
- test_encrypted_submissions_to_project_url()¶
Test encrypted submissions through the project URL endpoint.
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:
TestBaseTesting 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:
objectcreate_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_similar_uuid_submissions()¶
This test checks to make sure that instances with the same UUID are marked as duplicates.
- test_simple_yes_submission()¶
- test_start_time_boolean_properly_set()¶
onadata.apps.logger.tests.test_tasks module¶
Tests for module onadata.apps.logger.tasks
- class onadata.apps.logger.tests.test_tasks.AdjustXFormDecryptedSubmissionCountAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for adjust_xform_num_of_decrypted_submissions_async
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_adjust_xform_num_of_decrypted_submissions(mock_adjust)¶
Adjust XForm decrypted submission count
- test_invalid_pk(mock_logger, mock_adjust)¶
Invalid XForm primary key is handled
- test_retry_exceptions(mock_retry, mock_adjust)¶
ConnectionError and DatabaseError exceptions are retried
- class onadata.apps.logger.tests.test_tasks.CommitCachedXFormDecryptedSubmissionCountAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for commit_cached_xform_num_of_decrypted_submissions_async
- test_commit_cached_xform_num_of_decrypted_submissions(mock_commit)¶
Commit cached XForm decrypted submission count
- test_retry_exceptions(mock_retry, mock_commit)¶
ConnectionError and DatabaseError exceptions are retried
- class onadata.apps.logger.tests.test_tasks.CommitEListNumEntitiesAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests 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_exceptions(mock_retry, mock_commit)¶
ConnectionError and DatabaseError exceptions are retried
- class onadata.apps.logger.tests.test_tasks.DecryptInstanceAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for decrypt_instance_async
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_decrypt_instance(mock_decrypt)¶
Decrypt instance
- test_invalid_pk(mock_logger, mock_decrypt)¶
Invalid Instance primary key is handled
- test_max_retries_exceeded(mock_save_decryption_error, mock_decrypt)¶
Instance is tagged as failed decryption if max retries exceeded
- test_retry_exceptions(mock_retry, mock_decrypt)¶
ConnectionError and DatabaseError exceptions are retried
- class onadata.apps.logger.tests.test_tasks.DisableExpiredKeysAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for disable_expired_keys_async
- test_disable_expired_keys(mock_disable)¶
Disable expired keys
- test_retry_exceptions(mock_retry, mock_disable)¶
ConnectionError and DatabaseError exceptions are retried
- class onadata.apps.logger.tests.test_tasks.RotateExpiredKeysAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for rotate_expired_keys_async
- test_retry_exceptions(mock_retry, mock_rotate)¶
ConnectionError and DatabaseError exceptions are retried
- test_rotate_expired_keys(mock_rotate)¶
Rotate expired keys
- class onadata.apps.logger.tests.test_tasks.SendKeyGraceExpiryReminderAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for send_key_grace_expiry_reminder_async
- test_retry_exceptions(mock_retry, mock_send)¶
ConnectionError and DatabaseError exceptions are retried
- test_send_key_grace_expiry_reminder(mock_send)¶
Send key grace expiry reminder
- class onadata.apps.logger.tests.test_tasks.SendKeyRotationReminderAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests for send_key_rotation_reminder_async
- test_retry_exceptions(mock_retry, mock_send)¶
ConnectionError and DatabaseError exceptions are retried
- test_send_key_rotation_reminder(mock_send)¶
Send key rotation reminder
- class onadata.apps.logger.tests.test_tasks.SetEntityListPermsAsyncTestCase(methodName='runTest')¶
Bases:
TestBaseTests 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_exceptions(mock_retry, mock_set_perms)¶
ConnectionError, DatabaseError, OperationalError exceptions are retried
- test_set_perms(mock_set_perms)¶
Permissions are applied
- class onadata.apps.logger.tests.test_tasks.UpdateProjectDateModified(methodName='runTest')¶
Bases:
TestBaseTests 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_transfer_to_org()¶
Transferring to an organization works
- 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:
TestBaseCreated 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