當前位置: 首頁>>代碼示例>>Python>>正文


Python BackendMapping.delete方法代碼示例

本文整理匯總了Python中corehq.apps.sms.mixin.BackendMapping.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python BackendMapping.delete方法的具體用法?Python BackendMapping.delete怎麽用?Python BackendMapping.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在corehq.apps.sms.mixin.BackendMapping的用法示例。


在下文中一共展示了BackendMapping.delete方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: BaseReminderTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]
class BaseReminderTestCase(BaseAccountingTest):
    def setUp(self):
        super(BaseReminderTestCase, self).setUp()
        self.domain_obj = Domain(name="test")
        self.domain_obj.save()
        # Prevent resource conflict
        self.domain_obj = Domain.get(self.domain_obj._id)

        self.account, _ = BillingAccount.get_or_create_account_by_domain(
            self.domain_obj.name,
            created_by="tests"
        )
        advanced_plan_version = DefaultProductPlan.get_default_plan_by_domain(
            self.domain_obj, edition=SoftwarePlanEdition.ADVANCED)
        self.subscription = Subscription.new_domain_subscription(
            self.account,
            self.domain_obj.name,
            advanced_plan_version
        )
        self.subscription.is_active = True
        self.subscription.save()

        self.sms_backend = TestSMSBackend(named="MOBILE_BACKEND_TEST", is_global=True)
        self.sms_backend.save()

        self.sms_backend_mapping = BackendMapping(is_global=True,prefix="*",backend_id=self.sms_backend._id)
        self.sms_backend_mapping.save()

    def tearDown(self):
        self.sms_backend_mapping.delete()
        self.sms_backend.delete()
        SubscriptionAdjustment.objects.all().delete()
        self.subscription.delete()
        self.account.delete()
        self.domain_obj.delete()
開發者ID:puttarajubr,項目名稱:commcare-hq,代碼行數:37,代碼來源:__init__.py

示例2: OptTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]
class OptTestCase(BaseAccountingTest):
    def setUp(self):
        super(OptTestCase, self).setUp()
        self.domain = "opt-test"

        self.domain_obj = Domain(name=self.domain)
        self.domain_obj.save()

        generator.instantiate_accounting_for_tests()
        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain_obj.name, created_by="automated-test"
        )[0]
        plan = DefaultProductPlan.get_default_plan_by_domain(self.domain_obj, edition=SoftwarePlanEdition.ADVANCED)
        self.subscription = Subscription.new_domain_subscription(self.account, self.domain_obj.name, plan)
        self.subscription.is_active = True
        self.subscription.save()

        self.backend = TestSMSBackend(is_global=True)
        self.backend.save()

        self.backend_mapping = BackendMapping(is_global=True, prefix="*", backend_id=self.backend._id)
        self.backend_mapping.save()

    def test_opt_out_and_opt_in(self):
        self.assertEqual(PhoneNumber.objects.count(), 0)

        incoming("99912345678", "stop", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="99912345678")
        self.assertFalse(phone_number.send_sms)

        incoming("99912345678", "start", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="99912345678")
        self.assertTrue(phone_number.send_sms)

    def test_sending_to_opted_out_number(self):
        self.assertEqual(PhoneNumber.objects.count(), 0)
        self.assertTrue(send_sms(self.domain, None, "999123456789", "hello"))

        incoming("999123456789", "stop", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="999123456789")
        self.assertFalse(phone_number.send_sms)

        self.assertFalse(send_sms(self.domain, None, "999123456789", "hello"))

    def tearDown(self):
        self.backend_mapping.delete()
        self.backend.delete()
        self.domain_obj.delete()

        SubscriptionAdjustment.objects.all().delete()
        self.subscription.delete()
        self.account.delete()
開發者ID:johan--,項目名稱:commcare-hq,代碼行數:57,代碼來源:opt_tests.py

示例3: BaseReminderTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]
class BaseReminderTestCase(TestCase):
    def setUp(self):
        self.domain_obj = Domain(name="test")
        self.domain_obj.save()
        # Prevent resource conflict
        self.domain_obj = Domain.get(self.domain_obj._id)

        self.sms_backend = TestSMSBackend(named="MOBILE_BACKEND_TEST", is_global=True)
        self.sms_backend.save()

        self.sms_backend_mapping = BackendMapping(is_global=True,prefix="*",backend_id=self.sms_backend._id)
        self.sms_backend_mapping.save()

    def tearDown(self):
        self.sms_backend_mapping.delete()
        self.sms_backend.delete()
        self.domain_obj.delete()
開發者ID:SEL-Columbia,項目名稱:commcare-hq,代碼行數:19,代碼來源:__init__.py

示例4: OptTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]
class OptTestCase(TestCase):
    def setUp(self):
        self.domain = "opt-test"

        self.domain_obj = Domain(name=self.domain)
        self.domain_obj.save()

        self.backend = TestSMSBackend(is_global=True)
        self.backend.save()

        self.backend_mapping = BackendMapping(
            is_global=True,
            prefix="*",
            backend_id=self.backend._id,
        )
        self.backend_mapping.save()

    def test_opt_out_and_opt_in(self):
        self.assertEqual(PhoneNumber.objects.count(), 0)

        incoming("99912345678", "stop", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="99912345678")
        self.assertFalse(phone_number.send_sms)

        incoming("99912345678", "start", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="99912345678")
        self.assertTrue(phone_number.send_sms)

    def test_sending_to_opted_out_number(self):
        self.assertEqual(PhoneNumber.objects.count(), 0)
        self.assertTrue(send_sms(self.domain, None, "999123456789", "hello"))

        incoming("999123456789", "stop", "GVI")
        self.assertEqual(PhoneNumber.objects.count(), 1)
        phone_number = PhoneNumber.objects.get(phone_number="999123456789")
        self.assertFalse(phone_number.send_sms)

        self.assertFalse(send_sms(self.domain, None, "999123456789", "hello"))

    def tearDown(self):
        self.backend_mapping.delete()
        self.backend.delete()
        self.domain_obj.delete()
開發者ID:aristide,項目名稱:commcare-hq,代碼行數:47,代碼來源:opt_tests.py

示例5: TouchformsTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]

#.........這裏部分代碼省略.........
        return site

    def get_case(self, external_id):
        return get_one_case_in_domain_by_external_id(self.domain, external_id)

    def assertCasePropertyEquals(self, case, prop, value):
        self.assertEquals(case.get_case_property(prop), value)

    def get_last_form_submission(self):
        result = get_forms_by_type(self.domain, 'XFormInstance',
                                   recent_first=True, limit=1)
        return result[0] if len(result) > 0 else None

    def assertNoNewSubmission(self, last_submission):
        new_submission = self.get_last_form_submission()
        self.assertEquals(last_submission._id, new_submission._id)

    def assertFormQuestionEquals(self, form, question, value, cast=None):
        self.assertIn(question, form.form)
        form_value = form.form[question]
        if cast:
            form_value = cast(form_value)
        self.assertEquals(form_value, value)

    def get_last_outbound_sms(self, contact):
        # Not clear why this should be necessary, but without it the latest
        # sms may not be returned
        sleep(0.25)
        sms = SMSLog.view("sms/by_recipient",
            startkey=[contact.doc_type, contact._id, "SMSLog", "O", {}],
            endkey=[contact.doc_type, contact._id, "SMSLog", "O"],
            descending=True,
            include_docs=True,
            reduce=False,
        ).first()
        return sms

    def get_last_outbound_call(self, contact):
        # Not clear why this should be necessary, but without it the latest
        # call may not be returned
        sleep(0.25)
        call = CallLog.view("sms/by_recipient",
            startkey=[contact.doc_type, contact._id, "CallLog", "O", {}],
            endkey=[contact.doc_type, contact._id, "CallLog", "O"],
            descending=True,
            include_docs=True,
            reduce=False,
        ).first()
        return call

    def get_open_session(self, contact):
        return SQLXFormsSession.get_open_sms_session(self.domain, contact._id)

    def assertLastOutboundSMSEquals(self, contact, message):
        sms = self.get_last_outbound_sms(contact)
        self.assertIsNotNone(sms)
        self.assertEqual(sms.text, message)
        return sms

    def assertMetadataEqual(self, sms, xforms_session_couch_id=None, workflow=None):
        if xforms_session_couch_id:
            self.assertEqual(sms.xforms_session_couch_id, xforms_session_couch_id)
        if workflow:
            self.assertEqual(sms.workflow, workflow)

    def setUp(self):
        self.users = []
        self.apps = []
        self.keywords = []
        self.groups = []
        self.site = self.create_site()
        self.domain = "test-domain"
        self.domain_obj = self.create_domain(self.domain)
        self.create_web_user("touchforms_user", "123")

        self.backend = TestSMSBackend(name="TEST", is_global=True)
        self.backend.save()
        self.backend_mapping = BackendMapping(is_global=True, prefix="*",
            backend_id=self.backend._id)
        self.backend_mapping.save()

        settings.DEBUG = True

    def tearDown(self):
        for user in self.users:
            user.delete_verified_number()
            user.delete()
        for app in self.apps:
            app.delete()
        for keyword in self.keywords:
            keyword.delete()
        for group in self.groups:
            group.delete()
        self.domain_obj.delete()
        self.site.delete()
        self.backend.delete()
        self.backend_mapping.delete()
        SubscriptionAdjustment.objects.all().delete()
        self.subscription.delete()
        self.account.delete()
開發者ID:sheelio,項目名稱:commcare-hq,代碼行數:104,代碼來源:util.py

示例6: BackendTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping 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

示例7: BackendTestCase

# 需要導入模塊: from corehq.apps.sms.mixin import BackendMapping [as 別名]
# 或者: from corehq.apps.sms.mixin.BackendMapping import delete [as 別名]
class BackendTestCase(TestCase):
    def get_or_create_site(self):
        site, created = Site.objects.get_or_create(id=settings.SITE_ID)
        if created:
            site.domain = 'localhost'
            site.name = 'localhost'
            site.save()
        return (site, created)

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

        self.site, self.site_created = self.get_or_create_site()

        self.domain_obj = Domain(name=self.domain)
        self.domain_obj.save()

        generator.instantiate_accounting_for_tests()
        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain_obj.name,
            created_by="automated-test",
        )[0]
        plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain_obj, edition=SoftwarePlanEdition.ADVANCED
        )
        self.subscription = Subscription.new_domain_subscription(
            self.account,
            self.domain_obj.name,
            plan
        )
        self.subscription.is_active = True
        self.subscription.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()

#.........這裏部分代碼省略.........
開發者ID:aristide,項目名稱:commcare-hq,代碼行數:103,代碼來源:__init__.py


注:本文中的corehq.apps.sms.mixin.BackendMapping.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。