def tearDown(self): Dhis2Repeater.set_db(self.db)
def setUp(self): self.db = Dhis2Repeater.get_db() self.fakedb = FakeCouchDb() Dhis2Repeater.set_db(self.fakedb)
def setUp(self): self.db = Dhis2Repeater.get_db() self.fakedb = FakeCouchDb() Dhis2Repeater.set_db(self.fakedb) self.form = { "domain": DOMAIN, "form": { "@xmlns": "test_xmlns", "event_date": "2017-05-25T21:06:27.012000", "completed_date": "2017-05-25T21:06:27.012000", "event_location": "-33.6543213 19.12344312 abcdefg", "name": "test event", "meta": { "location": '', "timeEnd": "2017-05-25T21:06:27.012000", "timeStart": "2017-05-25T21:06:17.739000", "userID": self.user.user_id, "username": self.user.username } }, "received_on": "2017-05-26T09:17:23.692083Z", } self.config = { 'form_configs': json.dumps([{ 'xmlns': 'test_xmlns', 'program_id': 'test program', 'event_status': 'COMPLETED', 'completed_date': { 'doc_type': 'FormQuestion', 'form_question': '/data/completed_date', 'external_data_type': DHIS2_DATA_TYPE_DATE }, 'org_unit_id': { 'doc_type': 'FormUserAncestorLocationField', 'form_user_ancestor_location_field': LOCATION_DHIS_ID }, 'event_location': { 'form_question': '/data/event_location' }, 'datavalue_maps': [{ 'data_element_id': 'dhis2_element_id', 'value': { 'doc_type': 'FormQuestion', 'form_question': '/data/name' } }] }]) } config_form = Dhis2ConfigForm(data=self.config) self.assertTrue(config_form.is_valid()) data = config_form.cleaned_data conn = ConnectionSettings.objects.create(url="http://dummy.com", domain=DOMAIN) self.repeater = Dhis2Repeater(domain=DOMAIN, connection_settings_id=conn.id) self.repeater.dhis2_config.form_configs = [ Dhis2FormConfig.wrap(fc) for fc in data['form_configs'] ] self.repeater.save()