Пример #1
0
class TestRepeaterDeleted(BaseRepeaterTest):
    domain = 'rep-deleted'

    def setUp(self):
        super().setUp()
        self.connx = ConnectionSettings.objects.create(
            domain=self.domain,
            url='case-repeater-url',
        )
        self.repeater = CaseRepeater(
            domain=self.domain,
            connection_settings_id=self.connx.id,
            format='case_json',
        )
        self.repeater.save()
        self.post_xml(self.xform_xml, self.domain)
        self.repeater = reloaded(self.repeater)

    def tearDown(self):
        self.repeater.delete()
        # Making sure that SQL repeater are deleted after retire is called.
        SQLRepeater.all_objects.all().delete()
        self.connx.delete()
        FormProcessorTestUtils.delete_all_cases_forms_ledgers(self.domain)
        delete_all_repeat_records()
        super().tearDown()

    def test_trigger_when_deleted(self):
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CommCareCase.objects.get_case(CASE_ID, self.domain))
            _process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")

    def test_paused_then_deleted(self):
        self.repeater.pause()
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CommCareCase.objects.get_case(CASE_ID, self.domain))
            _process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")
Пример #2
0
class TestRepeaterDeleted(BaseRepeaterTest):
    domain = 'rep-deleted'

    def setUp(self):
        super().setUp()
        self.connx = ConnectionSettings.objects.create(
            domain=self.domain,
            url='case-repeater-url',
        )
        self.repeater = CaseRepeater(
            domain=self.domain,
            connection_settings_id=self.connx.id,
        )
        self.repeater.save()
        self.post_xml(self.xform_xml, self.domain)
        self.repeater = reloaded(self.repeater)

    def tearDown(self):
        self.repeater.delete()
        self.connx.delete()
        FormProcessorTestUtils.delete_all_cases_forms_ledgers(self.domain)
        delete_all_repeat_records()
        super().tearDown()

    @run_with_all_backends
    def test_trigger_when_deleted(self):
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CaseAccessors(self.domain_obj).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")

    @run_with_all_backends
    def test_paused_then_deleted(self):
        self.repeater.pause()
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CaseAccessors(self.domain_obj).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")
Пример #3
0
class TestRepeaterDeleted(BaseRepeaterTest):
    def setUp(self):
        super(TestRepeaterDeleted, self).setUp()
        self.domain_name = "test-domain"
        self.domain = create_domain(self.domain_name)

        self.repeater = CaseRepeater(
            domain=self.domain_name,
            url='case-repeater-url',
        )
        self.repeater.save()
        self.post_xml(self.xform_xml, self.domain_name)

    def tearDown(self):
        self.domain.delete()
        self.repeater.delete()
        delete_all_repeat_records()
        super(TestRepeaterDeleted, self).tearDown()

    @run_with_all_backends
    def test_trigger_when_deleted(self):
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CaseAccessors(self.domain).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")

    @run_with_all_backends
    def test_paused_then_deleted(self):
        self.repeater.pause()
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(
                CaseAccessors(self.domain).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type,
                             "RepeatRecord-Deleted")
Пример #4
0
class TestRepeaterDeleted(BaseRepeaterTest):
    def setUp(self):
        super(TestRepeaterDeleted, self).setUp()
        self.domain_name = "test-domain"
        self.domain = create_domain(self.domain_name)

        self.repeater = CaseRepeater(
            domain=self.domain_name,
            url='case-repeater-url',
        )
        self.repeater.save()
        self.post_xml(self.xform_xml, self.domain_name)

    def tearDown(self):
        self.domain.delete()
        self.repeater.delete()
        delete_all_repeat_records()
        super(TestRepeaterDeleted, self).tearDown()

    @run_with_all_backends
    def test_trigger_when_deleted(self):
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(CaseAccessors(self.domain).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type, "RepeatRecord-Deleted")

    @run_with_all_backends
    def test_paused_then_deleted(self):
        self.repeater.pause()
        self.repeater.retire()

        with patch.object(RepeatRecord, 'fire') as mock_fire:
            self.repeat_record = self.repeater.register(CaseAccessors(self.domain).get_case(CASE_ID))
            process_repeat_record(self.repeat_record)
            self.assertEqual(mock_fire.call_count, 0)
            self.assertEqual(self.repeat_record.doc_type, "RepeatRecord-Deleted")