onadata.libs.tests.utils package¶
Submodules¶
onadata.libs.tests.utils.test_analytics module¶
onadata.libs.tests.utils.test_api_export_tools module¶
Test api_export_tools module.
- class onadata.libs.tests.utils.test_api_export_tools.TestApiExportTools(methodName='runTest')¶
Bases:
TestBase
Test api_export_tools.
- google_credential = {'client_id': 'client-id', 'client_secret': 'client-secret', 'expiry': datetime.datetime(2016, 8, 18, 12, 43, 30, 316792), 'refresh_token': 'refresh-token', 'scopes': ['https://www.googleapis.com/auth/drive.file'], 'token_uri': 'https://oauth2.googleapis.com/token'}¶
- test_get_async_response_connection_error(AsyncResult)¶
Test get_async_response connection error.
- test_get_async_response_export_backlog_limit(AsyncResult)¶
Test get_async_response export backlog limit exceeded.
- test_get_async_response_export_does_not_exist(AsyncResult)¶
Test get_async_response export does not exist.
- test_get_async_response_when_result_changes_in_subsequent_calls(AsyncResult)¶
Test get_async_response export does not exist.
- test_get_existing_file_format()¶
Test existing form download format/ext.
- test_get_google_credentials()¶
Test create_async_export deletes credential when invalid
- test_get_google_credentials_valid()¶
Test create_async_export does not get rid of valid credential
- test_get_metadata_format()¶
Test metadata export format/ext.
- test_process_async_export_connection_error(mock_task)¶
Test process_async_export creates a new export.
- test_process_async_export_creates_new_export()¶
Test process_async_export creates a new export.
- test_process_async_export_returns_existing_export()¶
Test process_async_export returns existing export.
- test_response_for_format()¶
Test response format type.
onadata.libs.tests.utils.test_async_status module¶
onadata.libs.tests.utils.test_backup_tools module¶
onadata.libs.tests.utils.test_cache_tools module¶
Test onadata.libs.utils.cache_tools module.
- class onadata.libs.tests.utils.test_cache_tools.TestCacheTools(methodName='runTest')¶
Bases:
TestCase
Test onadata.libs.utils.cache_tools module class
- test_reset_project_cache()¶
Test reset_project_cache() function actually resets all project cache entries
- test_safe_key()¶
Test safe_key() function returns a hashed key
onadata.libs.tests.utils.test_chart_tools module¶
- class onadata.libs.tests.utils.test_chart_tools.TestChartTools(methodName='runTest')¶
Bases:
TestBase
- mock_get_abbreviated_xpath()¶
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_build_chart_category_field_group_by_category_field_in_group()¶
- test_build_chart_data_calculate_field_group_by_category_field()¶
- test_build_chart_data_cannot_group_by_field()¶
- test_build_chart_data_for_category_field_group_by_category_field()¶
- test_build_chart_data_for_field_on_duration()¶
- test_build_chart_data_for_field_on_grouped_field()¶
- test_build_chart_data_for_field_on_select_one()¶
- test_build_chart_data_for_field_on_submission_time()¶
- test_build_chart_data_for_field_on_submitted_by()¶
- test_build_chart_data_for_field_on_submitted_by_group_by()¶
- test_build_chart_data_for_field_with_language()¶
- test_build_chart_data_for_field_with_language_on_non_lang_field()¶
- test_build_chart_data_for_fields_with_accents()¶
- test_build_chart_data_for_fields_with_apostrophies()¶
Test that apostrophes are escaped before they are sent to the database.
If the not escaped a django.db.utils.ProgrammingError would be raised.
- test_build_chart_data_for_group_by_submitted_by()¶
- test_build_chart_data_for_non_numeric_field_group_by_two_fields()¶
- test_build_chart_data_for_numeric_field_group_by_category_field()¶
- test_build_chart_data_for_numeric_field_group_by_two_fields()¶
- test_build_chart_data_output()¶
- test_build_chart_data_strips_none_from_dates()¶
- test_build_chart_data_with_field_name_with_lengh_65()¶
- test_build_chart_data_with_nonexisting_field_xpath()¶
- test_get_choice_label_for_multi_select()¶
- test_get_choice_label_for_multi_select_with_spaces()¶
Select Multiple Fields with names with spaces will NEVER match their labels
- test_get_choice_label_when_label_not_in_choice_list()¶
- test_get_choice_label_with_list_label()¶
- test_get_choice_label_with_single_select()¶
- test_select_one_choices()¶
- test_select_one_choices_group_by()¶
- class onadata.libs.tests.utils.test_chart_tools.TestChartUtilFunctions(methodName='runTest')¶
Bases:
TestCase
- test_calculate_range_on_normal_values()¶
- test_calculate_range_when_page_is_beyond_limit()¶
- test_flatten_multiple_dict_into_one()¶
- test_raise_value_error_if_bad_time_zone()¶
- test_raise_value_error_if_no_match()¶
- test_utc_time_string_for_javascript()¶
- onadata.libs.tests.utils.test_chart_tools.find_field_by_name(xform, field_name)¶
- onadata.libs.tests.utils.test_chart_tools.find_field_by_xpath(xform, field_xpath)¶
onadata.libs.tests.utils.test_csv_builder module¶
Test CSVDataFrameBuilder
- class onadata.libs.tests.utils.test_csv_builder.TestCSVDataFrameBuilder(methodName='runTest')¶
Bases:
TestBase
CSVDataFrameBuilder test class
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- tearDown()¶
Hook method for deconstructing the test fixture after testing it.
- test_csv_column_indices_in_groups_within_repeats()¶
Test CSV column indices in groups within repeats.
- test_csv_columns_for_gps_within_groups()¶
Test CSV columns for GPS fields within groups.
- test_csv_dataframe_export_to()¶
Test CSVDataFrameBuilder.export_to().
- test_csv_export()¶
Test CSV export.
- test_csv_export_extra_columns()¶
Test CSV export EXTRA_COLUMNS
- test_csv_export_remove_group_name()¶
Test CSV export with remove_group_name option.
- test_csv_export_with_labels()¶
Test CSV export with labels.
- test_csv_export_with_labels_only()¶
Test CSV export with labels only.
- test_entity_list_dataset()¶
Export for an EntityList dataset is correct
- test_export_columns_register_missing()¶
Export columns register not found
- test_export_data_for_xforms_with_newer_submissions()¶
Test xform schema for form with no submission is successfully exported
- test_export_data_for_xforms_without_submissions()¶
Test xform schema for form with no submission is successfully exported
- test_export_register_merged_multiples()¶
Export register works with merged multiples
- test_export_register_split_multiples()¶
Export register works with split multiples
- test_extra_columns_dataview()¶
Extra columns are included in export for dataview
Extra columns included only if in the dataview
- test_format_mongo_data_for_csv()¶
Test format mongo data for CSV.
- test_get_prefix_from_xpath()¶
Test get_prefix_from_xpath(xpath) function.
- test_index_tag_replacement()¶
Test that the default index tags are correctly replaced by an underscore
- test_multiple_repeats_column_order()¶
Test the order of the columns in a multiple repeats form export
- test_no_split_select_multiples()¶
Test select multiples are not split within repeats.
- test_remove_dups_from_list_maintain_order()¶
Test remove_dups_from_list_maintain_order().
- test_remove_group_name_for_gps_within_groups()¶
Test gps CSV export with remove_group_name option.
- test_repeat_child_name_matches_repeat()¶
ParsedInstance.to_dict creates a list within a repeat if a child has the same name as the repeat. This test makes sure that doesnt happen
- test_select_multiples_grouped_repeating_w_split()¶
Select multiple choices within group within repeat with split
- test_select_multiples_grouped_repeating_wo_split()¶
Select multiple choices within group within repeat without split
- test_show_choice_labels()¶
Test show_choice_labels=true for select one questions.
- test_show_choice_labels_multi_language()¶
Test show_choice_labels=true for select one questions - multi language form.
- test_show_choice_labels_multi_language_1()¶
Test show_choice_labels=true for select one questions - multi language form selected language.
- test_show_choice_labels_select_multiple()¶
Test show_choice_labels=true for select multiple questions.
- test_show_choice_labels_select_multiple_1()¶
Test show_choice_labels=true, split_select_multiples=true and value_select_multiples=true for select multiple questions.
- test_show_choice_labels_select_multiple_1_language()¶
Test show_choice_labels=true, split_select_multiples=true and value_select_multiples=true for select multiple questions - multi language form.
- test_show_choice_labels_select_multiple_2()¶
Test show_choice_labels=true, split_select_multiples=true, binary_select_multiples=true for select multiple questions.
- test_show_choice_labels_select_multiple_3()¶
Test show_choice_labels=true, split_select_multiples=true, binary_select_multiples=false for select multiple questions.
- test_show_choice_labels_select_multiple_language()¶
Test show_choice_labels=true for select multiple questions - multi language form.
- test_split_gps_fields()¶
Test GPS fields data are split into latitude, longitude, altitude, and precision segments.
- test_split_gps_fields_within_repeats()¶
Test GPS fields data is split within repeats.
- test_split_select_multiples()¶
Test select multiples choices are split.
- test_split_select_multiples_values()¶
Test select multiples choices are split and their values as the data.
- test_split_select_multiples_with_randomize()¶
Test select multiples choices are split with the randomize option true.
- test_split_select_multiples_within_repeats()¶
Test select multiples choices are split within repeats in CSV exports.
- test_unicode_export()¶
Test write_to_csv() with unicode characters.
- test_windows_excel_compatible_csv_export()¶
Test window excel compatible CSV export.
- onadata.libs.tests.utils.test_csv_builder.xls_filepath_from_fixture_name(fixture_name)¶
Return an xls file path at tests/fixtures/[fixture]/fixture.xls
- onadata.libs.tests.utils.test_csv_builder.xml_inst_filepath_from_fixture_name(fixture_name, instance_name)¶
Returns the path to a fixture given fixture_name and instance_name.
onadata.libs.tests.utils.test_csv_import module¶
Tests the onadata.libs.utils.csv_import module
- class onadata.libs.tests.utils.test_csv_import.CSVImportTestCase(methodName='runTest')¶
Bases:
TestBase
Tests the onadata.libs.utils.csv_import module
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_csv_import_with_overwrite()¶
- test_csv_imports_are_tracked()¶
Test that submissions created via CSV Import are tracked
- test_csv_imports_initiator_stored()¶
Test that the user who imported data via CSV is tracked
- test_csv_with__more_than_4_repeats_import()¶
- test_csv_with_multiple_select_in_one_column()¶
- test_csv_with_repeats_import()¶
- test_data_upload(send_message_mock)¶
Data upload for submissions with no uuids
- test_enforces_data_type_and_rollback()¶
Test that data type constraints are enforced and instances created during the process are rolled back
- test_excel_date_conversion()¶
Convert date from 01/01/1900 to 01-01-1900
- test_get_async_csv_submission_status(AsyncResult)¶
- test_get_columns_by_type()¶
Test get_columns_by_type() returns columns in groups
- test_get_submission_meta_dict()¶
- test_import_non_utf8_csv()¶
- test_nested_geo_paths_csv()¶
- test_reject_spaces_in_headers()¶
- test_select_multiples_grouped_repeating_w_split()¶
Select multiple choices within group within repeat with split
- test_select_multiples_grouped_repeating_wo_split()¶
Select multiple choices within group within repeat without split
- test_submission_xls_to_csv()¶
Test that submission_xls_to_csv converts to csv
- test_submit_csv_and_rollback()¶
- test_submit_csv_edits(send_message_mock)¶
- test_submit_csv_instance_id_consistency(safe_create_instance)¶
- test_submit_csv_param_sanity_check()¶
- test_submit_csv_xml_location_property_test(d2x, safe_create_instance)¶
- test_submit_csv_xml_params(safe_create_instance)¶
- onadata.libs.tests.utils.test_csv_import.strip_xml_uuid(s)¶
onadata.libs.tests.utils.test_dict_tools module¶
onadata.libs.tests.utils.test_email module¶
Test onadata.utils.emails module.
- class onadata.libs.tests.utils.test_email.ProjectInvitationEmailTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for class ProjectInvitationEmail
- test_get_template_data()¶
Context data for the email templates is correct
- test_send(mock_send)¶
Email is sent successfully
- test_send_custom_message(mock_send)¶
Custom subject and message works
- class onadata.libs.tests.utils.test_email.ProjectInvitationURLTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for get_project_invitation_url
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_url_configured()¶
settings.PROJECT_INVITATION_URL is set
- test_url_configured_for_host()¶
settings.PROJECT_INVITATION_URL is set for specific host
- test_url_not_configured()¶
settings.PROJECT_INVITATION_URL not set
- class onadata.libs.tests.utils.test_email.TestEmail(methodName='runTest')¶
Bases:
TestBase
Test onadata.utils.email module
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_email_data_does_not_contain_newline_chars()¶
- test_get_verification_email_data_with_verification_and_redirect_urls()¶
- test_get_verification_email_data_with_verification_url_set()¶
- test_get_verification_email_data_without_verification_url_set()¶
- test_get_verification_url()¶
onadata.libs.tests.utils.test_export_builder module¶
Tests Export Builder Functionality
- class onadata.libs.tests.utils.test_export_builder.TestExportBuilder(methodName='runTest')¶
Bases:
TestBase
Test onadata.libs.utils.export_builder functions.
- data = [{'_review_comment': 'Wrong Location', '_review_date': '2021-05-25T02:27:19', '_review_status': 'Rejected', 'age': 35, 'children': [{'children/age': 5, 'children/cartoons': [{'children/cartoons/name': 'Tom & Jerry', 'children/cartoons/why': 'Tom is silly'}, {'children/cartoons/name': 'Flinstones', 'children/cartoons/why': 'I like bam bamć'}], 'children/fav_colors': 'red blue', 'children/iceLg==creams': 'vanilla chocolate', 'children/name': 'Mike'}, {'children/age': 2, 'children/cartoons': [], 'children/name': 'John'}, {'children/age': 3, 'children/cartoons': [{'children/cartoons/name': 'Shrek', 'children/cartoons/why': "He's so funny"}, {'children/cartoons/characters': [{'children/cartoons/characters/good_or_evil': 'good', 'children/cartoons/characters/name': 'Dee Dee'}, {'children/cartoons/characters/good_or_evil': 'evil', 'children/cartoons/characters/name': 'Dexter'}], 'children/cartoons/name': "Dexter's Lab", 'children/cartoons/why': 'He thinks hes smart'}], 'children/name': 'Imora'}], 'name': 'Abe', 'tel/telLg==office': '020123456'}, {'children': []}]¶
- data_utf8 = [{'age': 35, 'childrenLg==info': [{'childrenLg==info/age': 5, 'childrenLg==info/cartoons': [{'childrenLg==info/cartoons/name': 'Tom & Jerry', 'childrenLg==info/cartoons/why': 'Tom is silly'}, {'childrenLg==info/cartoons/name': 'Flinstones', 'childrenLg==info/cartoons/why': 'I like bam bamć'}], 'childrenLg==info/fav_colors': "red's blue's", 'childrenLg==info/ice_creams': 'vanilla chocolate', 'childrenLg==info/nameLg==first': 'Mike'}], 'name': 'Abe', 'tel/telLg==office': '020123456'}]¶
- long_survey_data = [{'age': 35, 'childrens_survey_with_a_very_lo': [{'childrens_survey_with_a_very_lo/age': 5, 'childrens_survey_with_a_very_lo/cartoons': [{'childrens_survey_with_a_very_lo/cartoons/name': 'Tom & Jerry', 'childrens_survey_with_a_very_lo/cartoons/why': 'Tom is silly'}, {'childrens_survey_with_a_very_lo/cartoons/name': 'Flinstones', 'childrens_survey_with_a_very_lo/cartoons/why': 'I like bam bamć'}], 'childrens_survey_with_a_very_lo/fav_colors': 'red blue', 'childrens_survey_with_a_very_lo/name': 'Mike'}, {'childrens_survey_with_a_very_lo/age': 2, 'childrens_survey_with_a_very_lo/cartoons': [], 'childrens_survey_with_a_very_lo/name': 'John'}, {'childrens_survey_with_a_very_lo/age': 3, 'childrens_survey_with_a_very_lo/cartoons': [{'childrens_survey_with_a_very_lo/cartoons/name': 'Shrek', 'childrens_survey_with_a_very_lo/cartoons/why': "He's so funny"}, {'childrens_survey_with_a_very_lo/cartoons/characters': [{'children/cartoons/characters/good_or_evil': 'good', 'childrens_survey_with_a_very_lo/cartoons/characters/name': 'Dee Dee'}, {'children/cartoons/characters/good_or_evil': 'evil', 'childrens_survey_with_a_very_lo/cartoons/characters/name': 'Dexter'}], 'childrens_survey_with_a_very_lo/cartoons/name': "Dexter's Lab", 'childrens_survey_with_a_very_lo/cartoons/why': 'He thinks hes smart'}], 'childrens_survey_with_a_very_lo/name': 'Imora'}], 'name': 'Abe'}]¶
- osm_data = [{'_review_comment': 'Wrong Location', '_review_date': '2021-05-25T02:27:19', '_review_status': 'Rejected', 'fav_color': 'red', 'osm_building': 'OSMWay34298972.osm', 'osm_building:building': 'yes', 'osm_building:building:levels': 4, 'osm_building:ctr:lat': '23.707316084046038', 'osm_building:ctr:lon': '90.40849938337506', 'osm_building:name': 'kol', 'osm_road': 'OSMWay234134797.osm', 'osm_road:ctr:lat': '23.708174238006087', 'osm_road:ctr:lon': '90.40946505581161', 'osm_road:highway': 'tertiary', 'osm_road:lanes': 2, 'osm_road:name': 'Patuatuli Road', 'photo': '1424308569120.jpg'}]¶
- test_build_sections_for_multilanguage_form()¶
- test_build_sections_from_survey()¶
- test_child_record_parent_table_is_updated_when_sheet_is_renamed()¶
- test_convert_types()¶
- test_csv_export_with_swahili_labels()¶
- test_decode_fields_names_encoded_for_mongo()¶
- test_decode_mongo_encoded_section_names()¶
- test_delimiter_replacement_works_existing_fields()¶
- test_delimiter_replacement_works_for_generated_gps_fields()¶
- test_delimiter_replacement_works_generated_multi_select_fields()¶
- test_export_with_image_attachments()¶
Test that the url for images is displayed correctly in exports
- test_export_zipped_zap_missing_en_label()¶
Blank language label defaults to label for default language
- test_extra_columns_dataview()¶
Extra columns are included in export for dataview
Extra columns included only if in the dataview
- test_generate_field_title()¶
- test_generate_field_title_truncated_titles()¶
- test_generate_field_title_truncated_titles_select_multiple()¶
- test_generation_of_gps_fields_works()¶
- test_generation_of_mongo_encoded_fields_works()¶
- test_generation_of_multi_selects_works()¶
- test_get_valid_sheet_name_catches_duplicates()¶
- test_get_valid_sheet_name_catches_long_duplicate_names()¶
- test_get_valid_sheet_name_catches_long_names()¶
- test_gps_xlsx_export_remove_group_name()¶
- test_mulsel_export_with_label_choices()¶
- test_no_group_name_gps_data()¶
Test that GPS Data is correctly exported when GPS Fields are within groups and the group name is removed
- test_sav_export_with_duplicate_metadata(mock_uuid)¶
Test that SAV exports work when a GPS Question is both in a group and outside of one
- test_select_multiples_choices()¶
- test_select_multiples_choices_with_choice_filter()¶
- test_show_choice_labels()¶
Test show_choice_labels=true for select one questions.
- test_show_choice_labels_multi_language()¶
Test show_choice_labels=true for select one questions - multi language form.
- test_show_choice_labels_select_multiple()¶
Test show_choice_labels=true for select multiple questions - split_select_multiples=true.
- test_show_choice_labels_select_multiple_1()¶
Test show_choice_labels=true for select multiple questions split_select_multiples=false.
- test_show_choice_labels_select_multiple_2()¶
Test show_choice_labels=true for select multiple questions split_select_multiples=false.
- test_show_choice_labels_select_multiple_language()¶
Test show_choice_labels=true for select multiple questions - multi language form.
- test_show_choice_labels_select_multiple_language_1()¶
Test show_choice_labels=true, split_select_multiples=true, for select multiple questions - multi language form.
- test_show_choice_labels_select_multiple_language_2()¶
Test show_choice_labels=true, split_select_multiples=true, binary_select_multiples=true for select multiple questions - multi language form.
- test_show_choice_labels_select_multiple_language_3()¶
Test show_choice_labels=true, split_select_multiples=true, value_select_multiples=true for select multiple questions - multi language form.
- test_split_gps_components_works()¶
- test_split_gps_components_works_when_gps_data_is_blank()¶
- test_split_select_multiples_choices_with_randomize_param()¶
Test that _get_select_mulitples_choices function generates choices correctly when random param set to true
- test_split_select_multiples_works()¶
Test split_select_multiples works as expected.
- test_split_select_multiples_works_when_data_is_blank()¶
- test_split_select_mutliples_works_with_int_value_in_row()¶
- test_string_to_date_with_xls_validation()¶
- test_to_sav_export()¶
- test_to_sav_export_language()¶
- test_to_sav_export_with_labels()¶
- test_to_xlsx_export_generates_valid_sheet_names()¶
- test_to_xlsx_export_respects_custom_field_delimiter()¶
- test_to_xlsx_export_works()¶
- test_type_conversion()¶
- test_xls_convert_dates_before_1900()¶
- test_xlsx_export_has_submission_review_fields()¶
Test that review comment, status and date fields are in xls exports
- test_xlsx_export_remove_group_name()¶
- test_xlsx_export_with_english_labels()¶
- test_xlsx_export_with_hxl_adds_extra_row()¶
- test_xlsx_export_with_labels()¶
- test_xlsx_export_with_labels_only()¶
- test_xlsx_export_with_osm_data()¶
Tests that osm data is included in xls export
- test_xlsx_export_with_swahili_labels()¶
- test_xlsx_export_works_with_unicode()¶
- test_zip_csv_export_has_submission_review_fields()¶
Test that review comment, status and date fields are in csv exports
- test_zipped_csv_export_remove_group_name()¶
cvs writer doesnt handle unicode we we have to encode to ascii
- test_zipped_csv_export_with_labels()¶
cvs writer doesnt handle unicode we we have to encode to ascii
- test_zipped_csv_export_with_labels_only()¶
csv writer does not handle unicode we we have to encode to ascii
- test_zipped_csv_export_with_osm_data()¶
Tests that osm data is included in zipped csv export
- test_zipped_csv_export_works()¶
- test_zipped_csv_export_works_with_unicode()¶
cvs writer doesnt handle unicode we we have to encode to ascii
- test_zipped_sav_export_dynamic_select_multiple()¶
- test_zipped_sav_export_external_choices()¶
Test that an SPSS export does not fail when it has choices from a file.
- test_zipped_sav_export_with_date_field()¶
- test_zipped_sav_export_with_duplicate_column_name()¶
Test that SAV exports with duplicate column names
- test_zipped_sav_export_with_duplicate_field_different_groups()¶
Test SAV exports duplicate fields, same group - one field in repeat
- This is to test the fixing of a curious bug which happens when:
You have duplicate fields in the same group
One of those fields is in a repeat
export_builder.TRUNCATE_GROUP_TITLE = True
- test_zipped_sav_export_with_duplicate_name_in_choice_list()¶
- test_zipped_sav_export_with_numeric_select_multiple_field()¶
- test_zipped_sav_export_with_numeric_select_one_field()¶
- test_zipped_sav_export_with_osm_data()¶
Test that osm data is included in zipped sav export
- test_zipped_sav_export_with_values_split_select_multiple()¶
- test_zipped_sav_export_with_zero_padded_select_multiple_field()¶
- test_zipped_sav_export_with_zero_padded_select_one_field()¶
- test_zipped_sav_has_submission_review_fields()¶
Test that review comment, status and date fields are in csv exports
onadata.libs.tests.utils.test_export_tools module¶
onadata.libs.tests.utils.test_image_tools module¶
onadata.libs.tests.utils.test_logger_tools module¶
Test logger_tools utility functions.
- class onadata.libs.tests.utils.test_logger_tools.CommitCachedEListNumEntitiesTestCase(methodName='runTest')¶
Bases:
EntityListNumEntitiesBase
Tests for method commit_cached_elist_num_entities
- test_cache_empty()¶
Empty cache is handled appropriately
- test_counter_commited()¶
Cached counter is commited in the database
- test_lock_already_acquired()¶
Commit unsuccessful if lock is already acquired
- class onadata.libs.tests.utils.test_logger_tools.CreateEntityFromInstanceTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for method create_entity_from_instance
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_entity_created()¶
Entity is created successfully
- test_grouped_section()¶
Entity properties within grouped section
- class onadata.libs.tests.utils.test_logger_tools.DecEListNumEntitiesTestCase(methodName='runTest')¶
Bases:
EntityListNumEntitiesBase
Tests for method dec_elist_num_entities
- test_cache_locked()¶
Database counter is decremented if cache is locked
- test_cache_unlocked()¶
Cache counter is decremented if cache is unlocked
- class onadata.libs.tests.utils.test_logger_tools.DeleteXFormSubmissionsTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for method delete_xform_submissions
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_action_recorded(mock_send_message)¶
Action is recorded in the audit log
- test_cache_deleted()¶
Cache tracking submissions being deleted is cleared
- test_hard_delete_all()¶
All submissions are hard deleted
- test_hard_delete_enabled()¶
Hard delete should be enabled for hard delete to be successful
- test_hard_delete_subset()¶
Subset of submissions are hard deleted
- test_project_date_modified_updated()¶
Project date_modified is updated to the current time
- test_sets_date_modified()¶
date_modified is set to the current time
- test_sets_deleted_at()¶
deleted_at is set to the current time
- test_sets_deleted_by()¶
Deleted_by is set to the user who initiated the deletion
- test_soft_delete_all()¶
All submissions are soft deleted
- test_soft_delete_subset()¶
Subset of submissions are soft deleted
- class onadata.libs.tests.utils.test_logger_tools.EntityListNumEntitiesBase(methodName='runTest')¶
Bases:
TestBase
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- class onadata.libs.tests.utils.test_logger_tools.IncEListNumEntitiesTestCase(methodName='runTest')¶
Bases:
EntityListNumEntitiesBase
Tests for method inc_elist_num_entities
- test_cache_locked()¶
Database counter is incremented if cache is locked
- test_cache_no_expire(mock_cache_add, mock_cache_set, mock_now)¶
Cached counter does not expire
Clean up should be done periodically such as in a background task
- test_cache_unlocked(mock_now)¶
Cache counter is incremented if cache is unlocked
- test_failover(mock_report_exc)¶
Failover is executed if commit timeout threshold exceeded
- test_failover_report_cache_hit(mock_report_exc)¶
Report exception not sent if cache elist-failover-report-sent set
- test_time_cache_set_once()¶
The cached time of creation is set once
- class onadata.libs.tests.utils.test_logger_tools.ReconstructXFormExportRegisterTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for method reconstruct_xform_export_register
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_register()¶
Repeats from all instances are registered
- test_register_not_found()¶
Register is created if not found
- class onadata.libs.tests.utils.test_logger_tools.RegisterInstanceRepeatColumnsTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for method register_instance_repeat_columns
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_columns_added()¶
Incoming columns are added to the register
- test_register_not_found()¶
Nothing happens if export columns register is not found
- test_select_multiples()¶
Columns for a form with select multiples are added
- class onadata.libs.tests.utils.test_logger_tools.TestLoggerTools(methodName='runTest')¶
Bases:
PyxformTestCase
,TestBase
Test logger_tools utility functions.
- test_attachment_file_name_validation()¶
Test that a clear exception is raised when an attachement is received whose file name exceeds 100 chars
- test_attachment_tracking()¶
Test that when a submission with many attachments is made, we keep track of the total number of attachments expected and if we have received all of them
- test_attachment_tracking_duplicate()¶
Test that duplicate attachments does not affect if all attachments were received.
- test_attachment_tracking_for_nested_repeats()¶
Test that when a submission with many attachments is made, we keep track of the total number of attachments expected and if we have received all of them
- test_attachment_tracking_for_repeats()¶
Test that when a submission with many attachments is made, we keep track of the total number of attachments expected and if we have received all of them
- test_attachment_tracking_not_in_submission()¶
Test attachment not in submission is not saved.
- test_check_encryption_status()¶
Test that the encryption status of a submission is checked and unencrypted submissions are rejected when made to encrypted forms.
- test_generate_content_disposition_header()¶
Test generate_content_disposition_header() function.
- test_get_first_record()¶
Test get_first_record() function.
- test_handle_parse_error()¶
Test that an invalid XML results is handled
- test_replaced_attachments_not_tracked()¶
Test that when a submission with an attachments is made, and later edited, whereby the attachment is replaced, the replaced attachment is no longer tracked for that submission
onadata.libs.tests.utils.test_middleware module¶
- class onadata.libs.tests.utils.test_middleware.MiddlewareTestCase(methodName='runTest')¶
Bases:
TestCase
- test_view_raise_OperationalError_exception()¶
Tests that the request raises an Operational Error. This test proves that the middleware class is able to intercept the exceptions raised and retry making the request
- test_view_without_exceptions()¶
Tests that requests without exceptions are handled normally and do not affect the normal runnings of the middleware class.
- onadata.libs.tests.utils.test_middleware.normal_view(request)¶
onadata.libs.tests.utils.test_model_tools module¶
onadata.libs.tests.utils.test_numeric module¶
onadata.libs.tests.utils.test_osm module¶
onadata.libs.tests.utils.test_password_validator module¶
- class onadata.libs.tests.utils.test_password_validator.PreviousPasswordValidatorTestCase(methodName='runTest')¶
Bases:
TestCase
Test case for the PreviousPasswordValidator class. Ensures correct behavior of password validation.
- test_allows_new_password()¶
Test validator allows new password not used before
- test_missing_pk()¶
Validator does not raise ValueError for missing pk
- test_reused_password()¶
Test ValidationError exception thrown on reused password
onadata.libs.tests.utils.test_project_utils module¶
Test onadata.libs.utils.project_utils
- class onadata.libs.tests.utils.test_project_utils.SetProjectPermsToObjectTestCase(methodName='runTest')¶
Bases:
TestBase
Tests for set_project_perms_to_object
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_owners_team_permissions()¶
Object permissions for owners group are set
- test_set_perms()¶
Project permissions are applied to object
- test_xform_creator()¶
XForm creator is made owner
- class onadata.libs.tests.utils.test_project_utils.TestProjectUtils(methodName='runTest')¶
Bases:
TestBase
Test project_utils module.
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- test_assign_change_asset_permission()¶
Test that the assign_change_asset_permission function calls the External service with the correct payload
- test_rabbitmq_connection_error(mock_set_perms_async, mock_set_perms)¶
Test rabbitmq connection error.
- test_retrieve_asset_permission()¶
Test that the retrieve_asset_permissions function calls the External service with the correct payload
- test_set_project_perms_to_xform()¶
Test set_project_perms_to_xform(xform, project)
- test_set_project_perms_to_xform_async(mock)¶
Test that the set_project_perms_to_xform_async task actually calls the set_project_perms_to_xform function
- test_set_project_perms_to_xform_async_mergedxform(mock)¶
set_project_perms_to_xform_async sets permissions for a MergedXForm
onadata.libs.tests.utils.test_qrcode module¶
onadata.libs.tests.utils.test_sorting module¶
- class onadata.libs.tests.utils.test_sorting.TestSorting(methodName='runTest')¶
Bases:
TestCase
- test_json_order_by()¶
Test that the json_order_by function works as intended 1. Generates correct SQL ORDER BY query for JSON Fields 2. Generates correct SQL ORDER BY query for none JSON fields;
Includes the model field in the generated SQL
- test_json_order_by_params()¶
Test that the json_order_by_params works as intended 1. Returns the correct JSON fields; without the - symbol 2. Excludes none JSON fields in the return; The json_order_by function
returns an SQL Statement with the fields in built
onadata.libs.tests.utils.test_viewer_tools module¶
Test onadata.libs.utils.viewer_tools.
- class onadata.libs.tests.utils.test_viewer_tools.TestViewerTools(methodName='runTest')¶
Bases:
TestBase
Test viewer_tools functions.
- test_create_attachments_zipfile_file_too_big(rpt_mock)¶
When a file is larger than what is allowed in settings an exception should be raised.
- test_export_def_from_filename()¶
Test export_def_from_filename().
- test_get_client_ip()¶
Test get_client_ip().
- test_get_enketo_defaults_with_multiple_params()¶
Test generate_enketo_form_defaults() with multiple params.
- test_get_enketo_defaults_with_non_existent_field()¶
Test generate_enketo_form_defaults() with non existent field.
- test_get_enketo_defaults_with_right_xform()¶
Test generate_enketo_form_defaults() with xform vars.
- test_get_enketo_defaults_without_vars()¶
Test generate_enketo_form_defaults() without vars.
- test_get_form()¶
Test get_form().
- test_get_form_url()¶
Test get_form_url().