onadata.apps.main.tests package

Submodules

onadata.apps.main.tests.test_audit_log module

class onadata.apps.main.tests.test_audit_log.TestAuditLog(methodName='runTest')

Bases: django.test.testcases.TestCase

test_audit_log_call()

onadata.apps.main.tests.test_base module

class onadata.apps.main.tests.test_base.TestBase(methodName='runTest')

Bases: pyxform.tests_v1.pyxform_test_case.PyxformMarkdown, django.test.testcases.TransactionTestCase

setUp()

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

surveys = ['transport_2011-07-25_19-05-49', 'transport_2011-07-25_19-05-36', 'transport_2011-07-25_19-06-01', 'transport_2011-07-25_19-06-14']
this_directory = '/home/onadata/app-versioned/1554726797/onadata/apps/main/tests'

onadata.apps.main.tests.test_csv_export module

Test CSV Exports

class onadata.apps.main.tests.test_csv_export.TestCsvExport(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

TestCSVExport class

setUp()

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

test_csv_export_output()

Test CSV export output

test_csv_nested_repeat_output()

Test CSV export with nested repeats

test_csv_repeat_with_note()

Test that note field in repeat is not in csv export

test_csv_truncated_titles()

Test CSV export with removed_group_name = True

test_dotted_fields_csv_export()

Test CSV export with dotted field names

onadata.apps.main.tests.test_custom_context_processors module

class onadata.apps.main.tests.test_custom_context_processors.CustomContextProcessorsTest(methodName='runTest')

Bases: django.test.testcases.TestCase

test_site_name()

onadata.apps.main.tests.test_form_api module

class onadata.apps.main.tests.test_form_api.TestFormAPI(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_api()
test_api_column_select()
test_api_cors_options()
test_api_count()
test_api_decode_from_mongo()
test_api_jsonp()
test_api_query_no_records()
test_api_with_or_query()

Test that an or query is interpreted correctly since we use an internal or query to filter out deleted records

test_api_with_query()
test_api_with_query_invalid_start_limit()
test_api_with_query_start_limit()
test_handle_bad_json()
onadata.apps.main.tests.test_form_api.dict_for_mongo_without_userform_id(parsed_instance)

onadata.apps.main.tests.test_form_api_delete module

class onadata.apps.main.tests.test_form_api_delete.TestFormAPIDelete(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_anon_user_cant_delete()
test_delete_shared()
test_get_request_does_not_delete()
test_owner_can_delete()

onadata.apps.main.tests.test_form_auth module

class onadata.apps.main.tests.test_form_auth.TestFormAuth(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_login_redirect_redirects()

onadata.apps.main.tests.test_form_edit module

class onadata.apps.main.tests.test_form_edit.TestFormEdit(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_anon_no_edit_post()
test_delete_404()
test_not_owner_no_edit_post()
test_user_data_license_edit_updates()
test_user_description_edit_updates()
test_user_form_license_edit_updates()
test_user_title_edit_updates()
test_user_toggle_data_privacy()
test_user_toggle_data_privacy_off()
test_user_toggle_form_downloadable()
test_user_toggle_form_downloadable_off()
test_user_toggle_form_privacy()
test_user_toggle_form_privacy_off()

onadata.apps.main.tests.test_form_enter_data module

class onadata.apps.main.tests.test_form_enter_data.TestFormEnterData(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_enketo_remote_server()
test_enketo_url_with_http_protocol_on_formlist()
test_enter_data_no_permission()
test_enter_data_non_existent_user()
test_enter_data_redir()
test_enter_data_with_unavailable_id_string()
test_qrcode_view()
test_qrcode_view_with_enketo_error()
onadata.apps.main.tests.test_form_enter_data.enketo_error_mock(url, request)
onadata.apps.main.tests.test_form_enter_data.enketo_mock(url, request)
onadata.apps.main.tests.test_form_enter_data.enketo_mock_http(url, request)

onadata.apps.main.tests.test_form_errors module

class onadata.apps.main.tests.test_form_errors.TestFormErrors(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_bad_id_string()
test_dl_no_xls()
test_dl_xls_not_file()
test_empty_submission()
test_nonexist_id_string()
test_spaced_xlsform()
test_submission_deactivated()

onadata.apps.main.tests.test_form_exports module

class onadata.apps.main.tests.test_form_exports.TestFormExports(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_allow_csv_export()
test_allow_csv_export_for_basic_auth()
test_allow_csv_export_if_shared()
test_allow_export_download_for_basic_auth()
test_allow_kml_export()
test_allow_kml_export_for_basic_auth()
test_allow_kml_export_if_shared()
test_allow_xls_export()
test_allow_xls_export_for_basic_auth()
test_allow_xls_export_if_shared()
test_allow_zip_export()
test_allow_zip_export_for_basic_auth()
test_allow_zip_export_if_shared()
test_csv_raw_export_name()
test_filter_by_date_csv()
test_filter_by_date_xls()
test_restrict_csv_export_if_not_shared()
test_restrict_kml_export_if_not_shared()
test_restrict_xls_export_if_not_shared()
test_restrict_zip_export_if_not_shared()
test_xls_raw_export_name()
test_zip_raw_export_name()

onadata.apps.main.tests.test_form_metadata module

class onadata.apps.main.tests.test_form_metadata.TestFormMetadata(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_add_media_url()
test_adds_mapbox_layer_on_submit()
test_adds_supporting_doc_on_submit()
test_adds_supporting_media_on_submit()
test_anon_delete_mapbox_layer()
test_delete_cached_xform_metadata_object_on_save()
test_delete_mapbox_layer()
test_delete_supporting_doc()
test_delete_supporting_media()
test_download_supporting_doc()
test_download_supporting_media()
test_media_file_hash()
test_no_download_supporting_doc_for_anon()
test_shared_download_supporting_doc_for_anon()
test_shared_download_supporting_media_for_anon()
test_shows_mapbox_layer_after_submit()
test_shows_supporting_doc_after_submit()
test_shows_supporting_media_after_submit()
test_upload_source_file()
test_upload_source_file_keep_name()
test_upload_source_file_set_value_to_name()
test_user_source_edit_updates()
test_views_with_unavailable_id_string()
test_windows_csv_file_upload()

onadata.apps.main.tests.test_form_permissions module

class onadata.apps.main.tests.test_form_permissions.TestFormPermissions(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_add_edit_to_user()
test_add_view_permisions_to_user()
test_add_view_to_user()
test_allow_map()
test_allow_map_if_shared()
test_allow_map_if_user_given_permission()
test_anon_reject_api()
test_client_allow_api()
test_disallow_map_if_user_permission_revoked()
test_remove_permissions_from_user()
test_require_owner_to_add_perm()
test_restrict_map_for_anon()
test_restrict_map_for_not_owner()
test_set_permissions_for_user()
test_show_list_of_users_shared_with()
test_view_shared_form()

onadata.apps.main.tests.test_form_public_api module

class onadata.apps.main.tests.test_form_public_api.TestFormPublicAPI(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_api()
test_api_with_unavailable_id_string()

onadata.apps.main.tests.test_form_show module

class onadata.apps.main.tests.test_form_show.TestFormShow(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_anon_no_edit_btn()
test_anon_no_toggle_data_share_btn()
test_delete_xforms_with_same_id_string_in_same_account(mock_get_object_or_404)
test_dl_json_for_basic_auth()
test_dl_json_for_cors_options()
test_dl_json_to_anon_if_public()
test_dl_jsonp_to_anon_if_public()
test_dl_xform_for_authenticated_non_owner()
test_dl_xform_for_basic_auth()
test_dl_xform_to_anon_if_public()
test_dl_xls_for_basic_auth()
test_dl_xls_to_anon_if_public()
test_dl_xlsx_xlsform()
test_enketo_preview()
test_enketo_preview_with_unavailable_id_string()
test_enketo_preview_works_on_shared_forms()
test_form_urls_case_insensitive()
test_hide_add_supporting_docs_if_not_owner()
test_hide_from_anon()
test_hide_from_not_user()
test_load_from_uuid()
test_load_photo_page()
test_non_owner_cannot_replace_form()

Test that a non owner cannot replace a shared xls form

test_non_owner_cant_delete_xform()
test_publish_xml_xlsform_download()
test_replace_xform()
test_return_error_if_xform_not_found()
test_show_add_mapbox_layer_if_owner()
test_show_add_sourc_doc_if_owner()
test_show_add_supporting_docs_if_owner()
test_show_add_supporting_media_if_owner()
test_show_form_name()
test_show_private_if_shared_but_not_data()
test_show_to_anon_if_public()
test_update_form_doesnt_truncate_to_50_chars()
test_user_sees_edit_btn()
test_user_sees_settings()
test_xform_delete()
test_xls_replace_markup()

Update form is only shown when no submissions and user = owner

onadata.apps.main.tests.test_form_show.raise_multiple_objects_returned_error(*args, **kwargs)

onadata.apps.main.tests.test_gps module

class onadata.apps.main.tests.test_gps.TestGPS(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_gps()

onadata.apps.main.tests.test_http_auth module

class onadata.apps.main.tests.test_http_auth.TestBasicHttpAuthentication(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_http_auth()
test_http_auth_shared_data()

onadata.apps.main.tests.test_metadata module

class onadata.apps.main.tests.test_metadata.TestMetaData(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_create_google_sheet_metadata_object()
test_create_metadata()
test_saving_same_metadata_object_doesnt_trigger_integrity_error()
test_unique_type_for_form()
test_upload_to_with_anonymous_user()
test_upload_to_with_project_and_xform_instance()

onadata.apps.main.tests.test_past_bugs module

class onadata.apps.main.tests.test_past_bugs.TestCascading(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_correct_id_string_picked()
class onadata.apps.main.tests.test_past_bugs.TestInputs(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

This is where I’ll input all files that proved problematic for users when uploading.

test_erics_files()
test_mch()
test_uniqueness_of_group_names_enforced()
class onadata.apps.main.tests.test_past_bugs.TestSubmissionBugs(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_submission_with_mixed_case_username()

onadata.apps.main.tests.test_process module

class onadata.apps.main.tests.test_process.TestProcess(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

ambulance_key = 'loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility'
bicycle_key = 'loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility'
frequency_str = 'frequency_to_referral_facility'
loop_str = 'loop_over_transport_types_frequency'
other_key = 'loop_over_transport_types_frequency/other/frequency_to_referral_facility'
setUp()

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

taxi_key = 'loop_over_transport_types_frequency/taxi/frequency_to_referral_facility'
tearDown()

Hook method for deconstructing the test fixture after testing it.

test_405_submission()
test_bad_url_upload()
test_csv_publishing()
test_google_url_upload(mock_urlopen)
test_metadata_file_hash()
test_multiple_submissions_by_different_users()

Two users publishing the same form breaks the CSV export.

test_not_logged_in_cannot_upload()
test_process(username=None, password=None)
test_publish_bad_xls_with_unicode_in_error()

Publish an xls where the error has a unicode character

Return a 200, thus showing a readable error to the user

test_publish_xlsx_file()
test_truncate_xform_title_to_255()
test_upload_all_xls()
test_url_upload(mock_urlopen)
test_url_upload_non_dot_xls_path()
test_uuid_injection_in_cascading_select()

Uuid is injected in the right instance for forms with cascading select

test_uuid_submit()
test_xls_export_content()
transport_ambulance_key = 'transport/loop_over_transport_types_frequency/ambulance/frequency_to_referral_facility'
transport_bicycle_key = 'transport/loop_over_transport_types_frequency/bicycle/frequency_to_referral_facility'
uuid_to_submission_times = {'5b2cc313-fc09-437e-8149-fcd32f695d41': '2013-02-14T15:37:21', '9c6f3468-cfda-46e8-84c1-75458e72805d': '2013-02-14T15:37:23', '9f0a1508-c3b7-4c99-be00-9b237c26bcbf': '2013-02-14T15:37:24', 'f3d8dc65-91a6-4d0f-9e97-802128083390': '2013-02-14T15:37:22'}

onadata.apps.main.tests.test_style module

class onadata.apps.main.tests.test_style.TestStyle(methodName='runTest')

Bases: django.test.testcases.TestCase

test_flake8()

onadata.apps.main.tests.test_user_id_string_unique_together module

class onadata.apps.main.tests.test_user_id_string_unique_together.TestUserIdStringUniqueTogether(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_unique_together()

Multiple users can have the same survey, but id_strings of surveys must be unique for a single user.

onadata.apps.main.tests.test_user_login module

class onadata.apps.main.tests.test_user_login.TestUserLogin(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

test_any_case_login_ok()
test_redirect_if_logged_in()
test_username_is_made_lower_case()

onadata.apps.main.tests.test_user_profile module

class onadata.apps.main.tests.test_user_profile.TestUserProfile(methodName='runTest')

Bases: django.test.testcases.TestCase

setup()
test_404_if_user_does_not_exist()
test_create_user_profile_for_user()
test_create_user_with_given_name()
test_disallow_non_alpha_numeric()
test_disallow_reserved_name()
test_xlsform_error_returns_400(mock_render)

onadata.apps.main.tests.test_user_settings module

class onadata.apps.main.tests.test_user_settings.TestUserSettings(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.TestBase

setUp()

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

test_access_user_settings_non_owner()
test_render_user_settings()
test_show_existing_profile_data()
test_update_user_settings()

Module contents