

@run_with_all_backends
def test_rule(self):
    now = datetime(2015, 10, 22, 0, 0)
    with patch('corehq.apps.data_interfaces.models.AutomaticUpdateRule.get_case_ids', new=self._get_case_ids):
        last_modified = datetime(2015, 9, 25, 12, 0)
        _update_case(self.domain, self.case_id, last_modified, date(2015, 9, 25))
        self._assert_case_revision(2, last_modified)
        run_case_update_rules_for_domain(self.domain, now=now)
        self._assert_case_revision(2, last_modified)
        last_modified = datetime(2015, 9, 20, 12, 0)
        _update_case(self.domain, self.case_id, last_modified, date(2015, 9, 25))
        self._assert_case_revision(3, last_modified)
        run_case_update_rules_for_domain(self.domain, now=now)
        self._assert_case_revision(3, last_modified)
        last_modified = datetime(2015, 9, 25, 12, 0)
        _update_case(self.domain, self.case_id, last_modified, date(2015, 9, 20))
        self._assert_case_revision(4, last_modified)
        run_case_update_rules_for_domain(self.domain, now=now)
        self._assert_case_revision(4, last_modified)
        last_modified = datetime(2015, 9, 20, 12, 0)
        _update_case(self.domain, self.case_id, last_modified, date(2015, 9, 20))
        self._assert_case_revision(5, last_modified)
        with drop_connected_signals(case_post_save):
            run_case_update_rules_for_domain(self.domain, now=now)
        self._assert_case_revision(6, last_modified, True)
        case = self._get_case()
        self.assertEqual(case.get_case_property('update_flag'), 'Y')
        self.assertEqual(case.closed, True)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/data_interfaces/tests/test_auto_case_updates.py AutomaticCaseUpdateTest.test_rule/original