def test_ziggy_to_formhub_instance(self): with open(cc_monthly_json_path) as f: json_post = json.load(f) ziggy_json = json_post[0] zi = ZiggyInstance.create_ziggy_instance(self.user, ziggy_json, self.user) formhub_dict = ziggy_to_formhub_instance(zi) expected_formhub_dict = { 'village_name': 'dygvbh', 'village_code': 'fjhgh', 'gps': '', 'reporting_month': '10-2013', 'households': '12', 'village_population': '2', 'improved_latrines': '5', 'latrines_smooth_cleanable_floor': '45', 'latrines_with_lid': '12', 'latrines_with_superstructure': '8', 'latrines_signs_of_use': '5', 'latrines_hand_washers': '12', 'latrines_all_improved_reqs': '', 'households_quality_checked': '4', 'checks_accurate': '9', 'today': '2013-08-23', '_userform_id': 'bob_cc_monthly_report_form' } self.assertDictEqual(formhub_dict, expected_formhub_dict)
def test_rest_service_ziggy_submission(self): with open(cc_monthly_json_path) as f: json_post = json.load(f) ziggy_json = json_post[0] zi = ZiggyInstance.create_ziggy_instance(self.user, ziggy_json, self.user) # check that the HTTP request was made with HTTMock(f2dhis_mock): services_called = rest_service_ziggy_submission( ZiggyInstance, zi, False, True, False) # make sure a service was called self.assertEqual(services_called, 1)