def setUp(self): super(ReportXformPillowTest, self).setUp() FormProcessorTestUtils.delete_all_xforms() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() ensure_index_deleted(REPORT_XFORM_INDEX_INFO.index) initialize_index_and_mapping(self.elasticsearch, REPORT_XFORM_INDEX_INFO)
def setUp(self): self.es = get_es_new() self.index = TEST_INDEX_INFO.index with trap_extra_setup(ConnectionError): ensure_index_deleted(self.index) initialize_index_and_mapping(self.es, TEST_INDEX_INFO)
def setUp(self): super(UserPillowTestBase, self).setUp() self.index_info = USER_INDEX_INFO self.elasticsearch = get_es_new() delete_all_users() ensure_index_deleted(self.index_info.index) initialize_index(self.elasticsearch, self.index_info)
def tearDownClass(cls): for form in cls.all_forms: form.delete() for app in cls.apps: app.delete() ensure_index_deleted(XFORM_INDEX_INFO.index) super(ExportsFormsAnalyticsTest, cls).tearDownClass()
def setUp(self): super(DomainPillowTest, self).setUp() self.index_info = DOMAIN_INDEX_INFO self.elasticsearch = get_es_new() delete_all_domains() ensure_index_deleted(self.index_info.index) initialize_index(self.elasticsearch, self.index_info)
def setUp(self): self.index_info = DOMAIN_INDEX_INFO self.elasticsearch = get_es_new() ensure_index_deleted(self.index_info.index) initialize_index(self.elasticsearch, self.index_info) import time time.sleep(1) # without this we get a 503 response about 30% of the time
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): with trap_extra_setup(ConnectionError): ensure_index_deleted(USER_INDEX) self.es_client = get_es_new() initialize_index_and_mapping(self.es_client, USER_INDEX_INFO) self.user_id = 'user1' _create_es_user(self.es_client, self.user_id, self.domain)
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 tearDown(self): ensure_index_deleted(CASE_SEARCH_INDEX) self.user.delete() self.domain.delete() for query_addition in CaseSearchQueryAddition.objects.all(): query_addition.delete() cache = get_redis_default_cache() cache.clear()
def setUp(self): self.pillow = TestElasticPillow(online=False) self.es = self.pillow.get_es_new() self.index = self.pillow.es_index with trap_extra_setup(ConnectionError): ensure_index_deleted(self.index) completely_initialize_pillow_index(self.pillow)
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 tearDown(self): ensure_index_deleted(self.es_index) self.couch_user.delete() self._clear_docs() self.teardown_subscription() super(ExportTest, self).tearDown()
def setUp(self): self.pillow = TestElasticPillow(online=False) self.es = self.pillow.get_es_new() self.index = self.pillow.es_index ensure_index_deleted(self.index) completely_initialize_pillow_index(self.pillow)
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 tearDownClass(cls): super(CallCenterLocationOwnerOptionsViewTest, cls).tearDownClass() for user in cls.users: user.delete() CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, False, NAMESPACE_DOMAIN) cls.domain.delete() cls.web_user.delete() ensure_index_deleted(USER_INDEX_INFO.index) ensure_index_deleted(GROUP_INDEX_INFO.index)
def setUpClass(cls): cls.pillow = pillow = XFormPillow() ensure_index_deleted(pillow.es_index) completely_initialize_pillow_index(pillow) cls._setup_domain_user() cls._setup_apps() cls._setup_forms() pillow.get_es_new().indices.refresh(pillow.es_index) cls.run_malt_generation()
def setUp(self): self.username = '******' self.first_name = 'clark' self.last_name = 'kent' self.doc_type = 'CommCareUser' self.domain = 'user-esaccessors-test' self.es = get_es_new() ensure_index_deleted(USER_INDEX) initialize_index_and_mapping(self.es, USER_INDEX_INFO)
def setUpClass(cls): cls.es = get_es_new() ensure_index_deleted(XFORM_INDEX_INFO.index) initialize_index_and_mapping(cls.es, XFORM_INDEX_INFO) cls._setup_domain_user() cls._setup_apps() cls._setup_forms() cls.es.indices.refresh(XFORM_INDEX_INFO.index) cls.run_malt_generation()
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 tearDown(self): ensure_index_deleted(XFORM_INDEX_INFO.index) self.couch_user.delete() self._clear_docs() self.domain.delete() self.teardown_subscription() clear_plan_version_cache() super(ExportTest, self).tearDown()
def setUp(self): self.user = CommCareUser.create(DOMAIN, 'user1', '***') self.request = Mock() self.request.method = 'POST' self.request.POST = {} self.request.project.commtrack_enabled = False self.request.couch_user = self.user.user_id with trap_extra_setup(ConnectionError): ensure_index_deleted(self.es_index) self.pillow = self.get_pillow()
def test_new_xform_reindexer(self): FormProcessorTestUtils.delete_all_xforms() form = _create_and_save_a_form() ensure_index_deleted(XFORM_INDEX) index_id = 'sql-form' if settings.TESTS_SHOULD_USE_SQL_BACKEND else 'form' call_command('ptop_reindexer_v2', index_id) XFormPillow().get_es_new().indices.refresh(XFORM_INDEX) self._assert_form_is_in_es(form)
def setUp(self): super(ReportUtilTests, self).setUp() self.user = CommCareUser.create(DOMAIN, 'user1', '***') self.request = Mock() self.request.method = 'POST' self.request.POST = {} self.request.project.commtrack_enabled = False self.request.couch_user = self.user.user_id with trap_extra_setup(ConnectionError): ensure_index_deleted(XFORM_INDEX_INFO.index) initialize_index_and_mapping(get_es_new(), XFORM_INDEX_INFO)
def test_domain_reindexer(self): delete_all_domains() ensure_index_deleted(DOMAIN_INDEX) name = 'reindex-test-domain' create_domain(name) call_command('ptop_reindexer_v2', index='domain', cleanup=True, noinput=True) results = DomainES().run() self.assertEqual(1, results.total, results.hits) domain_doc = results.hits[0] self.assertEqual(name, domain_doc['name']) self.assertEqual('Domain', domain_doc['doc_type']) delete_es_index(DOMAIN_INDEX)
def setUp(self): super(ExportTest, self).setUp() self._clear_docs() self.domain = create_domain(DOMAIN) self.setup_subscription(self.domain.name, SoftwarePlanEdition.ADVANCED) self.couch_user = WebUser.create(None, "test", "foobar") self.couch_user.add_domain_membership(DOMAIN, is_admin=True) self.couch_user.save() with trap_extra_setup(ConnectionError): ensure_index_deleted(self.es_index) self.pillow = self.get_pillow()
def setUp(self): super(ExportTest, self).setUp() self._clear_docs() self.domain = create_domain(DOMAIN) self.setup_subscription(self.domain.name, SoftwarePlanEdition.ADVANCED) self.couch_user = WebUser.create(None, "test", "foobar") self.couch_user.add_domain_membership(DOMAIN, is_admin=True) self.couch_user.save() with trap_extra_setup(ConnectionError): self.es = get_es_new() ensure_index_deleted(XFORM_INDEX_INFO.index) initialize_index_and_mapping(self.es, XFORM_INDEX_INFO)
def setUpClass(cls): super(CallCenterLocationOwnerOptionsViewTest, cls).setUpClass() with trap_extra_setup(ConnectionError, msg="cannot connect to elasicsearch"): es = get_es_new() ensure_index_deleted(USER_INDEX_INFO.index) ensure_index_deleted(GROUP_INDEX_INFO.index) initialize_index_and_mapping(es, USER_INDEX_INFO) initialize_index_and_mapping(es, GROUP_INDEX_INFO) # Create domain cls.domain = create_domain(TEST_DOMAIN) cls.domain.save() CALL_CENTER_LOCATION_OWNERS.set(cls.domain.name, True, NAMESPACE_DOMAIN) cls.username = "******" cls.password = "******" cls.web_user = WebUser.create(cls.domain.name, cls.username, cls.password) cls.web_user.save() # Create case sharing groups cls.groups = [] for i in range(2): group = Group(domain=TEST_DOMAIN, name="group{}".format(i), case_sharing=True) group.save() send_to_elasticsearch('groups', group.to_json()) cls.groups.append(group) es.indices.refresh(GROUP_INDEX_INFO.index) cls.group_ids = {g._id for g in cls.groups} # Create locations LocationType.objects.get_or_create( domain=cls.domain.name, name=LOCATION_TYPE, shares_cases=True, ) cls.locations = [ make_loc('loc{}'.format(i), type=LOCATION_TYPE, domain=TEST_DOMAIN) for i in range(4) ] cls.location_ids = {l._id for l in cls.locations} # Create users cls.users = [CommCareUser.create(TEST_DOMAIN, 'user{}'.format(i), '***') for i in range(3)] for user in cls.users: send_to_elasticsearch('users', user.to_json()) es.indices.refresh(USER_INDEX_INFO.index) cls.user_ids = {u._id for u in cls.users}
def test_get_all_commcare_users_by_domain(self): from corehq.util.elastic import ensure_index_deleted from corehq.elastic import get_es_new, send_to_elasticsearch from corehq.pillows.mappings.user_mapping import USER_INDEX_INFO, USER_INDEX from pillowtop.es_utils import initialize_index_and_mapping es = get_es_new() ensure_index_deleted(USER_INDEX) initialize_index_and_mapping(es, USER_INDEX_INFO) send_to_elasticsearch('users', self.ccuser_1.to_json()) send_to_elasticsearch('users', self.ccuser_2.to_json()) es.indices.refresh(USER_INDEX) usernames = lambda users: [u.username for u in users] # if no filters are passed, should return all cc-users in the domain self.assertItemsEqual( usernames(get_commcare_users_by_filters(self.ccdomain.name, {})), usernames([self.ccuser_2, self.ccuser_1]) ) self.assertEqual( get_commcare_users_by_filters(self.ccdomain.name, {}, count_only=True), 2 ) # can search by username self.assertItemsEqual( usernames(get_commcare_users_by_filters(self.ccdomain.name, {'search_string': 'user_1'})), [self.ccuser_1.username] ) self.assertEqual( get_commcare_users_by_filters(self.ccdomain.name, {'search_string': 'user_1'}, count_only=True), 1 ) # can search by role_id self.assertItemsEqual( usernames(get_commcare_users_by_filters(self.ccdomain.name, {'role_id': self.custom_role._id})), [self.ccuser_2.username] ) self.assertEqual( get_commcare_users_by_filters(self.ccdomain.name, {'role_id': self.custom_role._id}, count_only=True), 1 ) ensure_index_deleted(USER_INDEX)
def setUpClass(cls): super(GroupReindexerTest, cls).setUpClass() ensure_index_deleted(GROUP_INDEX_INFO.index)
def tearDown(self): ensure_index_deleted(CASE_SEARCH_INDEX) CaseSearchConfig.objects.all().delete() super(CaseSearchPillowTest, self).tearDown()
def setUp(self): self.index = TEST_INDEX_INFO.index self.es = get_es_new() with trap_extra_setup(ConnectionError): ensure_index_deleted(self.index)
def tearDown(self): ensure_index_deleted(CASE_INDEX_INFO.index)
def tearDown(self): ensure_index_deleted(self.index_info.index) super(UserPillowTestBase, self).tearDown()
def setUp(self): self.elasticsearch = get_es_new() for index in [GROUP_INDEX_INFO, USER_INDEX_INFO]: ensure_index_deleted(index.index) initialize_index(self.elasticsearch, index) delete_all_groups()
def tearDownClass(self): FormProcessorTestUtils.delete_all_cases() ensure_index_deleted(CASE_SEARCH_INDEX_INFO.index) super(TestFilterDslLookups, self).tearDownClass()
def tearDownClass(cls): ensure_index_deleted(USER_INDEX)
def tearDown(self): FormProcessorTestUtils.delete_all_cases() delete_all_users() ensure_index_deleted(CASE_SEARCH_INDEX_INFO.index) super().tearDown()
def tearDownClass(cls): ensure_index_deleted(CASE_INDEX_INFO.index) ensure_index_deleted(XFORM_INDEX_INFO.index) ensure_index_deleted(GROUP_INDEX_INFO.index)
def tearDown(self): ensure_index_deleted(CASE_INDEX_INFO.index) ensure_index_deleted(DOMAIN_INDEX_INFO.index) FormProcessorTestUtils.delete_all_cases_forms_ledgers(self.domain) super(ESAccessorsTest, self).tearDown()
def tearDownClass(cls): delete_all_users() cls.domain_obj.delete() ensure_index_deleted(USER_INDEX) super().tearDownClass()
def tearDown(self): FormProcessorTestUtils.delete_all_xforms() ensure_index_deleted(REPORT_XFORM_INDEX_INFO.index) super(ReportXformReindexerTest, self).tearDown()
def setUp(self): self.elasticsearch = get_es_new() ensure_index_deleted(GROUP_INDEX_INFO.index) initialize_index(self.elasticsearch, GROUP_INDEX_INFO) delete_all_groups()
def tearDownClass(cls): ensure_index_deleted(USER_INDEX) super(UserReindexerTest, cls).tearDownClass()
def tearDownClass(cls): ensure_index_deleted(LEDGER_INDEX_INFO.index)
def tearDown(self): ensure_index_deleted(self.es_index_info.index) super(BaseESAccessorsTest, self).tearDown()
def setUp(self): super(ReportXformReindexerTest, self).setUp() FormProcessorTestUtils.delete_all_xforms() with trap_extra_setup(ConnectionError): self.elasticsearch = get_es_new() ensure_index_deleted(REPORT_XFORM_INDEX_INFO.index)
def setUpClass(cls): ensure_index_deleted(GROUP_INDEX_INFO.index) cls.es = get_es_new() initialize_index_and_mapping(cls.es, GROUP_INDEX_INFO) cls.es.indices.refresh(GROUP_INDEX_INFO.index)
def tearDownClass(cls): ensure_index_deleted(GROUP_INDEX_INFO.index) super(GroupReindexerTest, cls).tearDownClass()
def setUpClass(cls): super(UserReindexerTest, cls).setUpClass() create_domain(DOMAIN) ensure_index_deleted(USER_INDEX)
def tearDownClass(cls): ensure_index_deleted(USER_INDEX) super(TestUserESAccessors, cls).tearDownClass()
def tearDownClass(cls): ensure_index_deleted(XFORM_INDEX_INFO.index) super(TestFixFormsWithMissingXmlns, cls).tearDownClass()
def _delete_es_index(self): if isinstance(self.es_index_info, (list, tuple)): for index_info in self.es_index_info: ensure_index_deleted(index_info.index) else: ensure_index_deleted(self.es_index_info.index)
def tearDownClass(cls): ensure_index_deleted(CASE_INDEX_INFO.index) super().tearDownClass()
def tearDown(self): ensure_index_deleted(self.index)
def tearDownClass(cls): for index in [CASE_SEARCH_INDEX, USER_INDEX, CASE_INDEX, XFORM_INDEX]: ensure_index_deleted(index) super(PillowtopReindexerTest, cls).tearDownClass()
def tearDown(self): ensure_index_deleted(GROUP_INDEX_INFO.index) ensure_index_deleted(USER_INDEX_INFO.index)
def tearDownClass(cls): ensure_index_deleted(CASE_INDEX_INFO.index) cache.clear() super(ExportTest, cls).tearDownClass()
def tearDown(self): ensure_index_deleted(self.index_info.index) super(DomainPillowTest, self).tearDown()