当前位置: 首页>>代码示例>>Python>>正文


Python CommCareCase.delete方法代码示例

本文整理汇总了Python中casexml.apps.case.models.CommCareCase.delete方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareCase.delete方法的具体用法?Python CommCareCase.delete怎么用?Python CommCareCase.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在casexml.apps.case.models.CommCareCase的用法示例。


在下文中一共展示了CommCareCase.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_date_case_properties_for_equality

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_date_case_properties_for_equality(self):
        """
        Date case properties are automatically converted from string to date
        when fetching from the db, so here we want to make sure this doesn't
        interfere with our ability to compare dates for equality.
        """
        case = CommCareCase(
            domain=self.domain,
            type='test-case-type-2',
        )

        self.rule2.automaticupdaterulecriteria_set = [
            AutomaticUpdateRuleCriteria(
                property_name='property1',
                property_value='2016-02-24',
                match_type=AutomaticUpdateRuleCriteria.MATCH_EQUAL,
            ),
        ]

        case.set_case_property('property1', '2016-02-24')
        case.save()
        case = CommCareCase.get(case.get_id)
        case.server_modified_on = datetime(2015, 1, 1)
        self.assertTrue(self.rule2.rule_matches_case(case, datetime(2016, 1, 1)))

        case.set_case_property('property1', '2016-02-25')
        case.save()
        case = CommCareCase.get(case.get_id)
        case.server_modified_on = datetime(2015, 1, 1)
        self.assertFalse(self.rule2.rule_matches_case(case, datetime(2016, 1, 1)))

        case.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:34,代码来源:test_auto_case_updates.py

示例2: test_phone_number_already_in_use

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_phone_number_already_in_use(self):
        case1 = CommCareCase(
            domain='case-phone-number-test',
            name='TEST1'
        )
        case1.set_case_property('contact_phone_number', '99987658765')
        case1.set_case_property('contact_phone_number_is_verified', '1')
        case1.save()

        case2 = CommCareCase(
            domain='case-phone-number-test',
            name='TEST2'
        )
        case2.set_case_property('contact_phone_number', '99987698769')
        case2.set_case_property('contact_phone_number_is_verified', '1')
        case2.save()

        self.assertIsNotNone(self.get_case_verified_number(case1))
        self.assertIsNotNone(self.get_case_verified_number(case2))

        case2.set_case_property('contact_phone_number', '99987658765')
        case2.save()
        self.assertIsNotNone(self.get_case_verified_number(case1))
        self.assertIsNone(self.get_case_verified_number(case2))

        case2.delete()
        self.get_case_verified_number(case1).delete()
        case1.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:30,代码来源:test_phone_numbers.py

示例3: test_date_case_properties_for_inequality

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_date_case_properties_for_inequality(self):
        case = CommCareCase(
            domain=self.domain,
            type='test-case-type-2',
        )

        self.rule2.automaticupdaterulecriteria_set = [
            AutomaticUpdateRuleCriteria(
                property_name='property1',
                property_value='2016-02-24',
                match_type=AutomaticUpdateRuleCriteria.MATCH_NOT_EQUAL,
            ),
        ]

        case.set_case_property('property1', '2016-02-24')
        case.save()
        case = CommCareCase.get(case.get_id)
        case.server_modified_on = datetime(2015, 1, 1)
        self.assertFalse(self.rule2.rule_matches_case(case, datetime(2016, 1, 1)))

        case.set_case_property('property1', '2016-02-25')
        case.save()
        case = CommCareCase.get(case.get_id)
        case.server_modified_on = datetime(2015, 1, 1)
        self.assertTrue(self.rule2.rule_matches_case(case, datetime(2016, 1, 1)))

        case.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:29,代码来源:test_auto_case_updates.py

示例4: TestUtilFunctions

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
class TestUtilFunctions(TestCase):
    def setUp(self):
        self.case = CommCareCase(domain='test-domain', name='test-case')
        self.case.save()

        self.user = CommCareUser.create('test-domain', 'test-user', '123')

    def test_get_contact(self):
        contact = get_contact(self.case.get_id)
        self.assertEqual(contact.get_id, self.case.get_id)
        self.assertTrue(isinstance(contact, CommConnectCase))

        contact = get_contact(self.user.get_id)
        self.assertEqual(contact.get_id, self.user.get_id)
        self.assertTrue(isinstance(contact, CommCareUser))

        try:
            get_contact('this-id-should-not-be-found')
        except Exception:
            pass
        else:
            self.assertTrue(False)

    def test_apply_leniency(self):
        self.assertEqual('16175551234', apply_leniency(' 1 (617) 555-1234 '))
        self.assertEqual('16175551234', apply_leniency(' 1.617.555.1234 '))
        self.assertEqual('16175551234', apply_leniency(' +1 617 555 1234 '))

    def tearDown(self):
        self.case.delete()
        self.user.delete()
开发者ID:johan--,项目名称:commcare-hq,代码行数:33,代码来源:__init__.py

示例5: UtilTestCase

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
class UtilTestCase(TestCase):
    
    def setUp(self):
        self.case = CommCareCase(domain='test-domain', name='test-case')
        self.case.save()
        self.user = CommCareUser.create('test-domain', 'test-user', '123')

    def tearDown(self):
        self.case.delete()
        self.user.delete()

    def testCleanPhoneNumber(self):
        phone_number = "  324 23-23421241"
        cleaned = clean_phone_number(phone_number)
        self.assertEquals(cleaned, "+3242323421241")

    def test_get_contact(self):
        contact = get_contact(self.case.get_id)
        self.assertEqual(contact.get_id, self.case.get_id)
        self.assertTrue(isinstance(contact, CommConnectCase))

        contact = get_contact(self.user.get_id)
        self.assertEqual(contact.get_id, self.user.get_id)
        self.assertTrue(isinstance(contact, CommCareUser))

        with self.assertRaises(ContactNotFoundException):
            get_contact('this-id-should-not-be-found')

    def test_apply_leniency(self):
        self.assertEqual('16175551234', apply_leniency(' 1 (617) 555-1234 '))
        self.assertEqual('16175551234', apply_leniency(' 1.617.555.1234 '))
        self.assertEqual('16175551234', apply_leniency(' +1 617 555 1234 '))
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:34,代码来源:test_util.py

示例6: test_get_list

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_get_list(self):
        """
        Any case in the appropriate domain should be in the list from the API.
        """

        # The actual infrastructure involves saving to CouchDB, having PillowTop
        # read the changes and write it to ElasticSearch.

        #the pillow is set to offline mode - elasticsearch not needed to validate
        pillow = CasePillow(online=False)
        fake_case_es = FakeXFormES()
        v0_4.MOCK_CASE_ES = fake_case_es

        modify_date = datetime.utcnow()

        backend_case = CommCareCase(server_modified_on=modify_date, domain=self.domain.name)
        backend_case.save()

        translated_doc = pillow.change_transform(backend_case.to_json())

        fake_case_es.add_doc(translated_doc['_id'], translated_doc)

        self.client.login(username=self.username, password=self.password)

        response = self.client.get(self.list_endpoint)
        self.assertEqual(response.status_code, 200)

        api_cases = simplejson.loads(response.content)['objects']
        self.assertEqual(len(api_cases), 1)

        api_case = api_cases[0]
        self.assertEqual(dateutil.parser.parse(api_case['server_date_modified']), backend_case.server_modified_on)

        backend_case.delete()
开发者ID:modonnell729,项目名称:commcare-hq,代码行数:36,代码来源:tests.py

示例7: saving

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
def saving(request):
    xform = XFormInstance(_attachments={'form.xml': {'data': '-'}})
    xform.save()
    case = CommCareCase()
    case.save()
    xform.initial_processing_complete = True
    xform.save()
    case.delete()
    xform.delete()
    return HttpResponse('Thanks for submitting', status=201)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:12,代码来源:views.py

示例8: test_invalid_phone_format

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_invalid_phone_format(self):
        case = CommCareCase(
            domain='case-phone-number-test',
            name='TEST1'
        )
        case.set_case_property('contact_phone_number', '99987658765')
        case.set_case_property('contact_phone_number_is_verified', '1')
        case.save()
        self.assertIsNotNone(self.get_case_verified_number(case))

        case.set_case_property('contact_phone_number', 'xyz')
        case.save()
        self.assertIsNone(self.get_case_verified_number(case))
        case.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:16,代码来源:test_phone_numbers.py

示例9: test_case_soft_delete

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_case_soft_delete(self):
        case = CommCareCase(
            domain='case-phone-number-test',
            name='TEST1'
        )
        case.set_case_property('contact_phone_number', '99987658765')
        case.set_case_property('contact_phone_number_is_verified', '1')
        case.save()
        self.assertIsNotNone(self.get_case_verified_number(case))

        case.doc_type += '-Deleted'
        case.save()
        self.assertIsNone(self.get_case_verified_number(case))
        case.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:16,代码来源:test_phone_numbers.py

示例10: test_case_zero_phone_number

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_case_zero_phone_number(self):
        case = CommCareCase(
            domain='case-phone-number-test',
            name='TEST1'
        )
        set_case_property_directly(case, 'contact_phone_number', '99987658765')
        set_case_property_directly(case, 'contact_phone_number_is_verified', '1')
        case.save()
        self.assertIsNotNone(self.get_case_verified_number(case))

        set_case_property_directly(case, 'contact_phone_number', '0')
        case.save()
        self.assertIsNone(self.get_case_verified_number(case))
        case.delete()
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:16,代码来源:test_phone_numbers.py

示例11: test_derived_properties

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_derived_properties(self):
        """
        Smoke test that the HOPE properties do not crash on a pretty empty CommCareCase
        """

        modify_date = datetime.utcnow()

        backend_case = CommCareCase(server_modified_on=modify_date, domain=self.domain.name)
        backend_case.save()

        # Rather than a re-fetch, this simulates the common case where it is pulled from ES
        hope_case = HOPECase.wrap(backend_case.to_json())

        self.hit_every_HOPE_property(hope_case)

        backend_case.delete()
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:18,代码来源:tests.py

示例12: MessageTestCase

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
class MessageTestCase(BaseReminderTestCase):

    def setUp(self):
        self.domain = "test"

        self.parent_case = CommCareCase(
            domain=self.domain,
            type="parent",
            name="P001",
        )
        self.parent_case.set_case_property("parent_prop1", "abc")
        self.parent_case.save()

        self.child_case = CommCareCase(
            domain=self.domain,
            type="child",
            name="P002",
            indices=[CommCareCaseIndex(
                identifier="parent",
                referenced_type="parent",
                referenced_id=self.parent_case._id,
            )],
        )
        self.child_case.set_case_property("child_prop1", "def")
        self.child_case.save()

    def tearDown(self):
        self.child_case.delete()
        self.parent_case.delete()

    def test_message(self):
        message = 'The EDD for client with ID {case.external_id} is approaching in {case.edd.days_until} days.'
        case = {'external_id': 123, 'edd': datetime.utcnow() + timedelta(days=30)}
        outcome = 'The EDD for client with ID 123 is approaching in 30 days.'
        self.assertEqual(Message.render(message, case=case), outcome)

    def test_template_params(self):
        child_result = {"case": self.child_case.case_properties()}
        child_result["case"]["parent"] = self.parent_case.case_properties()
        self.assertEqual(
            get_message_template_params(self.child_case), child_result)

        parent_result = {"case": self.parent_case.case_properties()}
        parent_result["case"]["parent"] = {}
        self.assertEqual(
            get_message_template_params(self.parent_case), parent_result)
开发者ID:aristide,项目名称:commcare-hq,代码行数:48,代码来源:__init__.py

示例13: testCaseAPIResultJSON

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def testCaseAPIResultJSON(self):
        try:
            case = CommCareCase()
            # because of how setattr is overridden you have to set it to None in this wacky way
            case._doc['type'] = None
            case.save()
            self.assertEqual(None, CommCareCase.get(case._id).type)
            res_sanitized = CaseAPIResult(id=case._id, couch_doc=case, sanitize=True)
            res_unsanitized = CaseAPIResult(id=case._id, couch_doc=case, sanitize=False)

            json = res_sanitized.case_json
            self.assertEqual(json['properties']['case_type'], '')

            json = res_unsanitized.case_json
            self.assertEqual(json['properties']['case_type'], None)
        finally:
            case.delete()
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:19,代码来源:test_api.py

示例14: test_case_phone_number_updates

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
    def test_case_phone_number_updates(self):
        case = CommCareCase(
            domain='case-phone-number-test',
            name='TEST1'
        )
        case.save()
        self.assertIsNone(self.get_case_verified_number(case))

        case.set_case_property('contact_phone_number', '99987658765')
        case.save()
        self.assertIsNone(self.get_case_verified_number(case))

        case.set_case_property('contact_phone_number_is_verified', '1')
        case.save()
        self.assertPhoneNumberDetails(case, '99987658765', None, None, _rev='1')
        _id = self.get_case_verified_number(case)._id

        case.set_case_property('contact_phone_number', '99987698769')
        case.save()
        self.assertPhoneNumberDetails(case, '99987698769', None, None, _id=_id, _rev='2')

        case.set_case_property('contact_backend_id', 'sms-backend')
        case.save()
        self.assertPhoneNumberDetails(case, '99987698769', 'sms-backend', None, _id=_id, _rev='3')

        case.set_case_property('contact_ivr_backend_id', 'ivr-backend')
        case.save()
        self.assertPhoneNumberDetails(case, '99987698769', 'sms-backend', 'ivr-backend', _id=_id, _rev='4')

        # If nothing changes, the phone entry should not be saved
        case.save()
        self.assertTrue(self.get_case_verified_number(case)._rev.startswith('4-'))

        # If phone entry is ahead of the case in terms of contact_last_modified, no update should happen
        v = self.get_case_verified_number(case)
        v.contact_last_modified += timedelta(days=1)
        v.save()
        self.assertTrue(v._rev.startswith('5-'))

        case.set_case_property('contact_phone_number', '99912341234')
        case.save()
        self.assertTrue(self.get_case_verified_number(case)._rev.startswith('5-'))

        self.get_case_verified_number(case).delete()
        case.delete()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:47,代码来源:test_phone_numbers.py

示例15: BackendTestCase

# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import delete [as 别名]
class BackendTestCase(TestCase):
    def setUp(self):
        self.domain = "test-domain"
        self.domain2 = "test-domain2"

        self.domain_obj = Domain(name=self.domain)
        self.domain_obj.save()
        self.domain_obj = Domain.get(self.domain_obj._id) # Prevent resource conflict

        self.backend1 = TestCaseBackend(name="BACKEND1",is_global=True)
        self.backend1.save()

        self.backend2 = TestCaseBackend(name="BACKEND2",is_global=True)
        self.backend2.save()

        self.backend3 = TestCaseBackend(name="BACKEND3",is_global=True)
        self.backend3.save()

        self.backend4 = TestCaseBackend(name="BACKEND4",is_global=True)
        self.backend4.save()

        self.backend5 = TestCaseBackend(name="BACKEND5",domain=self.domain,is_global=False,authorized_domains=[])
        self.backend5.save()

        self.backend6 = TestCaseBackend(name="BACKEND6",domain=self.domain2,is_global=False,authorized_domains=[self.domain])
        self.backend6.save()

        self.backend7 = TestCaseBackend(name="BACKEND7",domain=self.domain2,is_global=False,authorized_domains=[])
        self.backend7.save()
        
        self.backend8 = TestCaseBackend(name="BACKEND",domain=self.domain,is_global=False,authorized_domains=[])
        self.backend8.save()

        self.backend9 = TestCaseBackend(name="BACKEND",domain=self.domain2,is_global=False,authorized_domains=[self.domain])
        self.backend9.save()

        self.backend10 = TestCaseBackend(name="BACKEND",is_global=True)
        self.backend10.save()

        self.backend_mapping1 = BackendMapping(is_global=True,prefix="*",backend_id=self.backend1._id)
        self.backend_mapping1.save()

        self.backend_mapping2 = BackendMapping(is_global=True,prefix="1",backend_id=self.backend2._id)
        self.backend_mapping2.save()

        self.backend_mapping3 = BackendMapping(is_global=True,prefix="91",backend_id=self.backend3._id)
        self.backend_mapping3.save()

        self.backend_mapping4 = BackendMapping(is_global=True,prefix="265",backend_id=self.backend4._id)
        self.backend_mapping4.save()

        self.case = CommCareCase(domain=self.domain)
        self.case.set_case_property("contact_phone_number","15551234567")
        self.case.set_case_property("contact_phone_number_is_verified", "1")
        self.case.save()

        self.contact = CommConnectCase.wrap(self.case.to_json())

        settings.SMS_LOADED_BACKENDS.append("corehq.apps.sms.tests.TestCaseBackend")

    def tearDown(self):
        self.backend1.delete_invoke_doc()
        self.backend1.delete()
        self.backend_mapping1.delete()

        self.backend2.delete_invoke_doc()
        self.backend2.delete()
        self.backend_mapping2.delete()

        self.backend3.delete_invoke_doc()
        self.backend3.delete()
        self.backend_mapping3.delete()

        self.backend4.delete_invoke_doc()
        self.backend4.delete()
        self.backend_mapping4.delete()

        self.backend5.delete_invoke_doc()
        self.backend5.delete()

        self.backend6.delete_invoke_doc()
        self.backend6.delete()

        self.backend7.delete_invoke_doc()
        self.backend7.delete()

        self.contact.delete_verified_number()
        self.case.delete()

        self.domain_obj.delete()

        settings.SMS_LOADED_BACKENDS.pop()

    def test_backend(self):
        # Test the backend map

        self.assertTrue(send_sms(self.domain, None, "15551234567", "Test for BACKEND2"))
        self.assertFalse(self.backend1.invoke_doc_exists())
        self.assertTrue(self.backend2.invoke_doc_exists())
        self.assertFalse(self.backend3.invoke_doc_exists())
#.........这里部分代码省略.........
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:103,代码来源:__init__.py


注:本文中的casexml.apps.case.models.CommCareCase.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。