def setUp(self): super(CasePillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() initialize_index_and_mapping(self.elasticsearch, CASE_INDEX_INFO) delete_es_index(CASE_INDEX_INFO.index)
def tearDownClass(cls): cls.backend_mapping.delete() cls.backend.delete() FormProcessorTestUtils.delete_all_cases(cls.domain) cls.teardown_subscription() cls.domain_obj.delete() super(OptTestCase, cls).tearDownClass()
def setUp(self): super(ReportCaseReindexerTest, self).setUp() FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() ensure_index_deleted(REPORT_CASE_INDEX_INFO.index)
def setUp(self): super(ReportCaseReindexerTest, self).setUp() FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() ensure_index_deleted(REPORT_CASE_INDEX_INFO.index)
def setUp(self): super(CasePillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() initialize_index_and_mapping(self.elasticsearch, CASE_INDEX_INFO) delete_es_index(CASE_INDEX_INFO.index)
def setUp(self): FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms() self.domain = "domain" self.project = Domain(name=self.domain) self.user = User(user_id='user', username='******', password="******", date_joined=datetime(2011, 6, 9)) self.factory = CaseFactory() self.extension_ids = ['1', '2', '3'] self.host = CaseStructure(case_id='host') self.extension = CaseStructure( case_id=self.extension_ids[0], indices=[CaseIndex( related_structure=self.host, relationship="extension", )], ) self.extension_2 = CaseStructure( case_id=self.extension_ids[1], indices=[CaseIndex( related_structure=self.extension, relationship="extension", )], ) self.extension_3 = CaseStructure( case_id=self.extension_ids[2], indices=[CaseIndex( related_structure=self.extension_2, relationship="extension", )], )
def setUp(self): FormProcessorTestUtils.delete_all_cases(self.domain) FormProcessorTestUtils.delete_all_ledgers(self.domain) with trap_extra_setup(ConnectionError): self.pillow = get_ledger_to_elasticsearch_pillow() self.elasticsearch = get_es_new() ensure_index_deleted(LEDGER_INDEX_INFO.index) initialize_index_and_mapping(get_es_new(), LEDGER_INDEX_INFO)
def setUp(self): super(AppPillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.es = get_es_new() ensure_index_deleted(APP_INDEX_INFO.index) initialize_index_and_mapping(self.es, APP_INDEX_INFO)
def test_case_reindexer_v2(self): FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() index_id = 'sql-case' if settings.TESTS_SHOULD_USE_SQL_BACKEND else 'case' reindex_and_clean(index_id, reset=True) self._assert_case_is_in_es(case)
def tearDown(self): FormProcessorTestUtils.delete_all_cases(self.domain) PhoneBlacklist.objects.all().delete() delete_domain_phone_numbers(self.domain) self.backend_mapping.delete() self.backend.delete() self.domain_obj.delete() self.teardown_subscription()
def setUpClass(cls): super(NinetyNineDotsCaseTests, cls).setUpClass() FormProcessorTestUtils.delete_all_cases() cls.domain = 'enikshay-test' cls.factory = CaseFactory(domain=cls.domain) cls.person_id = "person" cls.occurrence_id = "occurrence" cls.episode_id = "episode"
def setUp(self): super(AppPillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.es = get_es_new() ensure_index_deleted(APP_INDEX_INFO.index) initialize_index_and_mapping(self.es, APP_INDEX_INFO)
def tearDownClass(cls): cls.backend_mapping.delete() cls.backend.delete() FormProcessorTestUtils.delete_all_cases(cls.domain) cls.teardown_subscription() cls.domain_obj.delete() clear_plan_version_cache() super(OptTestCase, cls).tearDownClass()
def setUp(self): FormProcessorTestUtils.delete_all_cases() self.elasticsearch = get_es_new() self.pillow = get_case_search_to_elasticsearch_pillow() ensure_index_deleted(CASE_SEARCH_INDEX) # Bootstrap ES initialize_index_and_mapping(get_es_new(), CASE_SEARCH_INDEX_INFO)
def test_case_reindexer_v2(self): FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() index_id = 'sql-case' reindex_and_clean(index_id, reset=True) self._assert_case_is_in_es(case)
def tearDown(self): FormProcessorTestUtils.delete_all_cases(self.domain) PhoneBlacklist.objects.all().delete() delete_domain_phone_numbers(self.domain) self.backend_mapping.delete() self.backend.delete() self.domain_obj.delete() self.teardown_subscription()
def test_case_reindexer_v2(self): FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() index_id = 'sql-case' if settings.TESTS_SHOULD_USE_SQL_BACKEND else 'case' call_command('ptop_reindexer_v2', index_id, cleanup=True, noinput=True, reset=True) self._assert_case_is_in_es(case)
def setUp(self): super(LedgerPillowTestCouch, self).setUp() FormProcessorTestUtils.delete_all_ledgers(self.domain) FormProcessorTestUtils.delete_all_cases(self.domain) with trap_extra_setup(ConnectionError): self.pillow = get_ledger_to_elasticsearch_pillow() self.elasticsearch = get_es_new() ensure_index_deleted(LEDGER_INDEX_INFO.index) initialize_index_and_mapping(get_es_new(), LEDGER_INDEX_INFO)
def setUp(self): super(CaseSearchPillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() self.elasticsearch = get_es_new() self.pillow = get_case_pillow(skip_ucr=True) ensure_index_deleted(CASE_SEARCH_INDEX) # Bootstrap ES initialize_index_and_mapping(get_es_new(), CASE_SEARCH_INDEX_INFO)
def setUp(self): self.domain = 'case_search_es' super(TestCaseSearchLookups, self).setUp() FormProcessorTestUtils.delete_all_cases() self.elasticsearch = get_es_new() ensure_index_deleted(CASE_SEARCH_INDEX) # Bootstrap ES initialize_index_and_mapping(get_es_new(), CASE_SEARCH_INDEX_INFO)
def setUp(self): super(CasePillowTest, self).setUp() self.process_case_changes = process_pillow_changes('DefaultChangeFeedPillow') self.process_case_changes.add_pillow('case-pillow', {'skip_ucr': True}) FormProcessorTestUtils.delete_all_cases() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() initialize_index_and_mapping(self.elasticsearch, CASE_INDEX_INFO) initialize_index_and_mapping(self.elasticsearch, CASE_SEARCH_INDEX_INFO)
def setUp(self): super(CaseSearchPillowTest, self).setUp() FormProcessorTestUtils.delete_all_cases() self.elasticsearch = get_es_new() self.pillow = get_case_pillow(skip_ucr=True) ensure_index_deleted(CASE_SEARCH_INDEX) # Bootstrap ES initialize_index_and_mapping(get_es_new(), CASE_SEARCH_INDEX_INFO)
def test_new_case_reindexer(self): FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() ensure_index_deleted(CASE_INDEX) # new reindexer doesn't force delete the index so do it in the test index_id = 'sql-case' if settings.TESTS_SHOULD_USE_SQL_BACKEND else 'case' call_command('ptop_reindexer_v2', index_id) CasePillow().get_es_new().indices.refresh(CASE_INDEX) # as well as refresh the index self._assert_case_is_in_es(case)
def setUp(self): FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms() delete_all_users() self.domain = "domain" self.project = Domain(name=self.domain) self.user = create_restore_user(self.domain, username='******', password="******") self.factory = CaseFactory(domain=self.domain) self.extension_ids = ['1', '2', '3'] self.host_id = 'host'
def setUp(self): super(AutoCloseExtensionsTest, self).setUp() FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms() delete_all_users() self.domain = "domain" self.project = Domain(name=self.domain) self.user = create_restore_user(self.domain, username='******', password="******") self.factory = CaseFactory(domain=self.domain) self.extension_ids = ['1', '2', '3'] self.host_id = 'host'
def test_case_reindexer(self): FormProcessorTestUtils.delete_all_cases() case_name = 'reindexer-test-case-{}'.format(uuid.uuid4().hex) with drop_connected_signals(case_post_save): CommCareCase(domain=self.domain, name=case_name).save() call_command('ptop_fast_reindex_cases', noinput=True, bulk=True) results = CaseES().run() self.assertEqual(1, results.total) case_doc = results.hits[0] self.assertEqual(self.domain, case_doc['domain']) self.assertEqual(case_name, case_doc['name']) self.assertEqual('CommCareCase', case_doc['doc_type'])
def test_case_search_reindexer(self): es = get_es_new() FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() ensure_index_deleted(CASE_SEARCH_INDEX) # With case search not enabled, case should not make it to ES CaseSearchConfig.objects.all().delete() call_command('ptop_reindexer_v2', 'case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_es_empty(esquery=CaseSearchES()) # With case search enabled, it should get indexed CaseSearchConfig.objects.create(domain=self.domain, enabled=True) self.addCleanup(CaseSearchConfig.objects.all().delete) call_command('ptop_reindexer_v2', 'case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_case_is_in_es(case, esquery=CaseSearchES())
def test_case_search_reindexer(self): es = get_es_new() FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() ensure_index_deleted(CASE_SEARCH_INDEX) # With case search not enabled, case should not make it to ES CaseSearchConfig.objects.all().delete() call_command('ptop_reindexer_v2', 'case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_es_empty(esquery=CaseSearchES()) # With case search enabled, it should get indexed CaseSearchConfig.objects.create(domain=self.domain, enabled=True) self.addCleanup(CaseSearchConfig.objects.all().delete) call_command('ptop_reindexer_v2', 'case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_case_is_in_es(case, esquery=CaseSearchES())
def test_case_search_reindexer(self): es = get_es_new() FormProcessorTestUtils.delete_all_cases() case = _create_and_save_a_case() ensure_index_deleted(CASE_SEARCH_INDEX) # With case search not enabled, case should not make it to ES CaseSearchConfig.objects.all().delete() domains_needing_search_index.clear() reindex_and_clean('case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_es_empty(esquery=CaseSearchES()) # With case search enabled, it should get indexed with mock.patch('corehq.pillows.case_search.domains_needing_search_index', mock.MagicMock(return_value=[self.domain])): reindex_and_clean('case-search') es.indices.refresh(CASE_SEARCH_INDEX) # as well as refresh the index self._assert_case_is_in_es(case, esquery=CaseSearchES())
def test_get_case_by_external_id(self): case1 = _create_case(domain=DOMAIN) case1.external_id = '123' CaseAccessorSQL.save_case(case1) case2 = _create_case(domain='d2', case_type='t1') case2.external_id = '123' CaseAccessorSQL.save_case(case2) self.addCleanup(lambda: FormProcessorTestUtils.delete_all_cases('d2')) [case] = CaseAccessorSQL.get_cases_by_external_id(DOMAIN, '123') self.assertEqual(case.case_id, case1.case_id) [case] = CaseAccessorSQL.get_cases_by_external_id('d2', '123') self.assertEqual(case.case_id, case2.case_id) self.assertEqual([], CaseAccessorSQL.get_cases_by_external_id('d2', '123', case_type='t2'))
def test_get_case_by_external_id(self): case1 = _create_case(domain=DOMAIN) case1.external_id = '123' CaseAccessorSQL.save_case(case1) case2 = _create_case(domain='d2', case_type='t1') case2.external_id = '123' CaseAccessorSQL.save_case(case2) self.addCleanup(lambda: FormProcessorTestUtils.delete_all_cases('d2')) [case] = CaseAccessorSQL.get_cases_by_external_id(DOMAIN, '123') self.assertEqual(case.case_id, case1.case_id) [case] = CaseAccessorSQL.get_cases_by_external_id('d2', '123') self.assertEqual(case.case_id, case2.case_id) self.assertEqual([], CaseAccessorSQL.get_cases_by_external_id('d2', '123', case_type='t2'))
def test_get_case_by_external_id(self): case1 = _create_case(external_id='123') case2 = _create_case(domain='d2', case_type='t1', external_id='123') if settings.USE_PARTITIONED_DATABASE: self.addCleanup( lambda: FormProcessorTestUtils.delete_all_cases('d2')) case = CommCareCase.objects.get_case_by_external_id(DOMAIN, '123') self.assertEqual(case.case_id, case1.case_id) case = CommCareCase.objects.get_case_by_external_id('d2', '123') self.assertEqual(case.case_id, case2.case_id) case = CommCareCase.objects.get_case_by_external_id('d2', '123', case_type='t2') self.assertIsNone(case)
def tearDown(self): FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() ensure_index_deleted(REPORT_CASE_INDEX_INFO.index) super(ReportCaseReindexerTest, self).tearDown()
def setUp(self): self.formdb = FormAccessors() FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms()
def tearDownClass(cls): FormProcessorTestUtils.delete_all_cases(DOMAIN) FormProcessorTestUtils.delete_all_xforms(DOMAIN) super(FundamentalCaseTests, cls).tearDownClass()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() super(TestFormArchiving, self).tearDown()
def setUpClass(cls): super(ENikshayCaseUtilsTests, cls).setUpClass() FormProcessorTestUtils.delete_all_cases()
def setUp(self): super(BaseCaseMultimediaTest, self).setUp() self.formdb = FormAccessors() FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms()
def tearDown(self): FormProcessorTestUtils.delete_all_cases(self.domain_name) delete_all_repeat_records() super(CaseRepeaterTest, self).tearDown()
def tearDown(self): FormProcessorTestUtils.delete_all_cases() super(IndexTest, self).tearDown()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms(self.domain.name) FormProcessorTestUtils.delete_all_cases(self.domain.name) self.couch_user.delete() self.domain.delete()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms(self.domain) FormProcessorTestUtils.delete_all_cases(self.domain)
def tearDownClass(cls): delete_indicator_doc() FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() super(IndicatorPillowTests, cls).tearDownClass()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms() FormProcessorTestUtils.delete_all_cases() super(TestFormArchiving, self).tearDown()
def tearDown(self): FormProcessorTestUtils.delete_all_cases(self.domain_name) delete_all_repeat_records() super(CaseRepeaterTest, self).tearDown()
def tearDownClass(cls): FormProcessorTestUtils.delete_all_cases() ensure_index_deleted(CASE_SEARCH_INDEX_INFO.index) super().tearDownClass()
def tearDown(self): FormProcessorTestUtils.delete_all_cases(self.domain) delete_all_repeat_records() super().tearDown()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms(DOMAIN) FormProcessorTestUtils.delete_all_cases(DOMAIN)
def tearDown(self): FormProcessorTestUtils.delete_all_xforms(DOMAIN) FormProcessorTestUtils.delete_all_cases(DOMAIN)
def setUp(self): FormProcessorTestUtils.delete_all_cases() self.pillow = CasePillow() self.elasticsearch = self.pillow.get_es_new() delete_es_index(self.pillow.es_index)
def delete_all_cases(): FormProcessorTestUtils.delete_all_cases()
def tearDownClass(cls): cls.user.delete() cls.domain_object.delete() FormProcessorTestUtils.delete_all_cases() super(TestZapierCreateCaseAction, cls).tearDownClass()
def tearDown(self): from corehq.form_processor.tests.utils import FormProcessorTestUtils FormProcessorTestUtils.delete_all_xforms(self.domain.name) FormProcessorTestUtils.delete_all_cases(self.domain.name)
def setUp(self): super(BaseCaseMultimediaTest, self).setUp() self.formdb = FormAccessors() FormProcessorTestUtils.delete_all_cases() FormProcessorTestUtils.delete_all_xforms()
def tearDown(self): super(ENikshayCaseUtilsTests, self).tearDown() FormProcessorTestUtils.delete_all_cases()
def delete_all_cases(): FormProcessorTestUtils.delete_all_cases()
def setUpClass(cls): super(FundamentalCaseTests, cls).setUpClass() FormProcessorTestUtils.delete_all_cases(DOMAIN) FormProcessorTestUtils.delete_all_xforms(DOMAIN)
def tearDown(self): AutomaticUpdateRuleCriteria.objects.all().delete() AutomaticUpdateAction.objects.all().delete() AutomaticUpdateRule.objects.all().delete() FormProcessorTestUtils.delete_all_cases(self.domain)
def tearDown(self): FormProcessorTestUtils.delete_all_cases() delete_all_users() ensure_index_deleted(CASE_SEARCH_INDEX_INFO.index) super().tearDown()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms(self.domain) FormProcessorTestUtils.delete_all_cases(self.domain) UnfinishedSubmissionStub.objects.all().delete()