onadata.libs.tests.utils package

Submodules

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: onadata.apps.main.tests.test_base.TestBase

Test api_export_tools.

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_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

class onadata.libs.tests.utils.test_async_status.TestAsyncStatus(methodName='runTest')

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

test_async_status()
test_celery_state_to_status()

onadata.libs.tests.utils.test_backup_tools module

class onadata.libs.tests.utils.test_backup_tools.TestBackupRestore(methodName='runTest')

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

setUp()

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

test_restore_backup_from_path()
test_restore_from_xml_file()

onadata.libs.tests.utils.test_chart_tools module

class onadata.libs.tests.utils.test_chart_tools.TestChartTools(methodName='runTest')

Bases: onadata.apps.main.tests.test_base.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: unittest.case.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: onadata.apps.main.tests.test_base.TestBase

CSVDataFrameBuilder test class

setUp()

Hook method for setting up the test fixture before exercising 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_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(mock_query_data)

Test the order of the columns in a multiple repeats form export

test_no_split_select_multiples(mock_query_data)

Test select multiples are not split within repeats.

test_remove_dups_from_list_maintain_order()

Test remove_dups_from_list_maintain_order().

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_show_choice_labels(mock_query_data)

Test show_choice_labels=true for select one questions.

test_show_choice_labels_multi_language(mock_query_data)

Test show_choice_labels=true for select one questions - multi language form.

test_show_choice_labels_multi_language_1(mock_query_data)

Test show_choice_labels=true for select one questions - multi language form selected language.

test_show_choice_labels_select_multiple(mock_query_data)

Test show_choice_labels=true for select multiple questions.

test_show_choice_labels_select_multiple_1(mock_query_data)

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(mock_query_data)

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(mock_query_data)

Test show_choice_labels=true, split_select_multiples=true, binary_select_multiples=true for select multiple questions.

test_show_choice_labels_select_multiple_3(mock_query_data)

Test show_choice_labels=true, split_select_multiples=true, binary_select_multiples=false for select multiple questions.

test_show_choice_labels_select_multiple_language(mock_query_data)

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_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

class onadata.libs.tests.utils.test_csv_import.CSVImportTestCase(methodName='runTest')

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

setUp()

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

test_csv_with__more_than_4_repeats_import()
test_csv_with_multiple_select_in_one_column()
test_csv_with_repeats_import()
test_data_upload()

Data upload for submissions with no uuids

test_excel_date_conversion()

Convert date from 01/01/1900 to 01-01-1900

test_get_async_csv_submission_status(AsyncResult)
test_get_submission_meta_dict()
test_import_non_utf8_csv()
test_nested_geo_paths_csv()
test_reject_spaces_in_headers()
test_submission_xls_to_csv()

Test that submission_xls_to_csv converts to csv

test_submit_csv_and_rollback()
test_submit_csv_edits()
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

class onadata.libs.tests.utils.test_dict_tools.TestDictTools(methodName='runTest')

Bases: unittest.case.TestCase

maxDiff = None
test_csv_repeat_field_to_dict()
test_lookup_path()

onadata.libs.tests.utils.test_export_tools module

Test export_tools module

class onadata.libs.tests.utils.test_export_tools.TestExportTools(methodName='runTest')

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

Test export_tools functions.

test_encode_if_str()
test_export_not_found()
test_generate_attachments_zip_export()
test_generate_filtered_attachments_zip_export()

Test media zip file export filters attachments

test_generate_osm_export()
test_get_attachment_uri_for_filename_with_space()
test_get_repeat_index_tags()

Test get_repeat_index_tags(index_tags) function.

test_get_sav_value_labels()
test_get_sav_value_labels_for_choice_filter()
test_get_sav_value_labels_multi_language()
test_get_value_or_attachment_uri()
test_kml_export_data()

Test kml_export_data(id_string, user, xform=None).

test_kml_exports()

Test generate_kml_export()

test_parse_request_export_options()
test_retrieving_pending_export()
test_sav_choice_list_with_missing_values()
test_sav_duplicate_columns()
test_sav_special_char_columns()
test_should_create_new_export()
test_should_create_new_export_when_filter_defined()
test_should_not_create_new_export_when_old_exists()
test_str_to_bool()

onadata.libs.tests.utils.test_image_tools module

class onadata.libs.tests.utils.test_image_tools.TestImageTools(methodName='runTest')

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

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_resize()
test_resize_exception_is_handled()
onadata.libs.tests.utils.test_image_tools.image_url_mock(url, request)

onadata.libs.tests.utils.test_logger_tools module

class onadata.libs.tests.utils.test_logger_tools.TestLoggerTools(methodName='runTest')

Bases: pyxform.tests_v1.pyxform_test_case.PyxformTestCase, onadata.apps.main.tests.test_base.TestBase

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_generate_content_disposition_header()
test_get_first_record()

Test get_first_record() function.

onadata.libs.tests.utils.test_osm module

class onadata.libs.tests.utils.test_osm.TestOSM(methodName='runTest')

Bases: unittest.case.TestCase

test_include_osm_id_in_tags()
test_parse_osm()
test_parse_osm_node()
test_parse_osm_node_faulty()
test_parse_osm_tags()
test_parse_osm_ways()

onadata.libs.tests.utils.test_qrcode module

class onadata.libs.tests.utils.test_qrcode.TestGenerateQrCode(methodName='runTest')

Bases: unittest.case.TestCase

test_generate_qrcode()

Module contents