def handle(self, **options): verify_only = options.get("verify_only", False) skip_verify = options.get("skip_verify", False) doc_count = len(get_all_repeater_docs()) sql_doc_count = SQLRepeater.objects.count() print( f"Found {doc_count} Repeater docs and {sql_doc_count} SQL Repeater models" ) all_commands = [ 'migrate_shortformrepeater', 'migrate_createcaserepeater', 'migrate_refercaserrepeater', 'migrate_dhis2repeater', 'migrate_formrepeater', 'migrate_userrepeater', 'migrate_fhirrepeater', 'migrate_appstructurerepeater', 'migrate_caserepeater', 'migrate_caseexpressionrepeater', 'migrate_dataregistrycaseupdaterepeater', 'migrate_dhis2entityrepeater', 'migrate_openmrsrepeater', 'migrate_locationrepeater', 'migrate_updatecaserepeater', 'migrate_beneficiaryregistrationrepeater', 'migrate_beneficiaryvaccinationrepeater' ] for cmd in all_commands: call_command(cmd, verify_only=verify_only, skip_verify=skip_verify)
def test_repeatrs_retired_from_sql(self): for r in self.all_sql_repeaters: r.save() self.all_sql_repeaters[0].retire() self.all_sql_repeaters[4].retire() couch_repeater_count = len(get_all_repeater_docs()) sql_repeater_count = SQLRepeater.objects.all().count() self.assertEqual(couch_repeater_count, sql_repeater_count)
def test_repeaters_are_synced_to_couch(self): repeaters = get_all_repeater_docs() self.assertEqual(len(repeaters), 4) self.assertEqual({r['_id'] for r in repeaters}, {r.repeater_id for r in self.all_repeaters}) self.assertEqual({Repeater.wrap(r).repeater_type for r in repeaters}, {r.repeater_type for r in self.all_repeaters})
def test_repeaters_are_synced_to_couch(self): repeaters = get_all_repeater_docs() self.assertEqual(len(repeaters), 4) self.assertEqual({r['_id'] for r in repeaters}, { self.createcase_repeater_obj.repeater_id, self.case_repeater_obj.repeater_id, self.refercase_repeater_obj.repeater_id, self.dataregistry_repeater_obj.repeater_id }) self.assertEqual({Repeater.wrap(r).repeater_type for r in repeaters}, { self.createcase_repeater_obj.repeater_type, self.case_repeater_obj.repeater_type, self.refercase_repeater_obj.repeater_type, self.dataregistry_repeater_obj.repeater_type })
def _get_all_couch_docs_for_model(self): return [ repeater for repeater in get_all_repeater_docs() if repeater['doc_type'] == self.couch_doc_type() ]
def test_get_all_repeater_docs(self): repeaters = get_all_repeater_docs() self.assertEqual(len(repeaters), 2)
def count_items_to_be_migrated(cls): couch_count = len(get_all_repeater_docs()) sql_count = SQLRepeater.objects.count() return couch_count - sql_count