Ejemplo n.º 1
0
    def test_case_soft_deletion(self):
        # make a case
        case_id = uuid.uuid4().hex
        case_name = 'case-name-{}'.format(uuid.uuid4().hex)
        case = make_a_case(self.domain, case_id, case_name)

        # send to elasticsearch
        self._sync_couch_cases_to_es()

        # verify there
        results = CaseES().run()
        self.assertEqual(1, results.total)

        seq_before_deletion = self.pillow.get_change_feed().get_latest_change_id()

        # soft delete the case
        case.soft_delete()

        # sync to elasticsearch
        self._sync_couch_cases_to_es(since=seq_before_deletion)

        # ensure not there anymore
        results = CaseES().run()
        self.assertEqual(0, results.total)

        # cleanup
        case.delete()
Ejemplo n.º 2
0
    def test_case_pillow_sql(self):
        consumer = get_test_kafka_consumer(topics.CASE_SQL)
        # have to get the seq id before the change is processed
        kafka_seq = consumer.offsets()['fetch'][(topics.CASE_SQL, 0)]

        # make a case
        case_id = uuid.uuid4().hex
        case_name = 'case-name-{}'.format(uuid.uuid4().hex)
        case = make_a_case(self.domain, case_id, case_name)

        # confirm change made it to kafka
        message = consumer.next()
        change_meta = change_meta_from_kafka_message(message.value)
        self.assertEqual(case.case_id, change_meta.document_id)
        self.assertEqual(self.domain, change_meta.domain)

        # send to elasticsearch
        sql_pillow = get_sql_case_to_elasticsearch_pillow()
        sql_pillow.process_changes(since=kafka_seq, forever=False)
        self.elasticsearch.indices.refresh(self.pillow.es_index)

        # confirm change made it to elasticserach
        results = CaseES().run()
        self.assertEqual(1, results.total)
        case_doc = results.hits[0]
        self.assertEqual(self.domain, case_doc['domain'])
        self.assertEqual(case_id, case_doc['_id'])
        self.assertEqual(case_name, case_doc['name'])
Ejemplo n.º 3
0
    def test_case_pillow_couch(self):
        # make a case
        case_id = uuid.uuid4().hex
        case_name = 'case-name-{}'.format(uuid.uuid4().hex)
        case = make_a_case(self.domain, case_id, case_name)

        # send to elasticsearch
        self._sync_couch_cases_to_es()

        # verify there
        results = CaseES().run()
        self.assertEqual(1, results.total)
        case_doc = results.hits[0]
        self.assertEqual(self.domain, case_doc['domain'])
        self.assertEqual(case_id, case_doc['_id'])
        self.assertEqual(case_name, case_doc['name'])

        # cleanup
        case.delete()
Ejemplo n.º 4
0
def _create_and_save_a_case():
    case_name = 'reindexer-test-case-{}'.format(uuid.uuid4().hex)
    case_id = uuid.uuid4().hex
    return make_a_case(DOMAIN, case_id, case_name)