Beispiel #1
0
    def test_casedb_already_has_cases(self):
        case = CaseFactory().create_case()
        case_db = CaseDbCache(initial=[CommCareCase(_id='fake1'), CommCareCase(_id='fake2')])
        form = XFormInstance.get(case.xform_ids[0])

        def assert_exactly_one_case(sender, xform, cases, **kwargs):
            global case_count
            case_count = len(cases)

        cases_received.connect(assert_exactly_one_case)
        try:
            process_cases_with_casedb([form], case_db)
            self.assertEqual(1, case_count)
        finally:
            cases_received.disconnect(assert_exactly_one_case)
Beispiel #2
0
    def test_casedb_already_has_cases(self):
        casedb_cache = FormProcessorInterface().casedb_cache
        case = CaseFactory().create_case()
        case_db = casedb_cache(initial=[CommCareCase(_id='fake1'), CommCareCase(_id='fake2')])
        form = XFormInstance.get(case.xform_ids[0])

        def assert_exactly_one_case(sender, xform, cases, **kwargs):
            global case_count
            case_count = len(cases)

        cases_received.connect(assert_exactly_one_case)
        try:
            process_cases_with_casedb([form], case_db)
            self.assertEqual(1, case_count)
        finally:
            cases_received.disconnect(assert_exactly_one_case)
Beispiel #3
0
    def test_casedb_already_has_cases(self):
        casedb_cache = FormProcessorInterface().casedb_cache
        case = CaseFactory().create_case()
        case_db = casedb_cache(initial=[
            CommCareCase(case_id='fake1'),
            CommCareCase(case_id='fake2'),
        ])
        form = XFormInstance.objects.get_form(case.xform_ids[0])
        received = []

        def receive_cases(sender, xform, cases, **kwargs):
            received.extend(cases)

        cases_received.connect(receive_cases)
        try:
            process_cases_with_casedb([form], case_db)
            self.assertEqual(len(received), 1)
        finally:
            cases_received.disconnect(receive_cases)