コード例 #1
0
class TestSmsGatewayWebService(unittest.TestCase):
    
    def setUp(self):
        self.dlrProcessor = DlrProcessor()
        self.web          = DummySite(ATStagingWebResource(self.dlrProcessor))

    @defer.inlineCallbacks
    def test_safaricomSmsGateway(self):
        request = yield self.web.post("sms-gateway/safaricom", 
                                      {"transactionId" : "TxnId1",
                                       "to"            : "+254718008164,+254729891801"})
        self.assertEquals(request.responseCode, 201)
        the_page = "".join(request.written)
        self.assertEquals(the_page, json.dumps({"Message": "Success"}))

    @defer.inlineCallbacks
    def test_kenyaSmsGateway(self):
        request = yield self.web.post("sms-gateway/kenya",
                                      {"transactionId": "TxnId1",
                                       "destination": "+254738008164,+254739891801"})
        self.assertEquals(request.responseCode, 201)
        the_page = "".join(request.written)
        transactionData = {"TransactionData" : {"+254738008164" : "1701",
                                                "+254739891801" : "1701"}}
        self.assertEquals(the_page, json.dumps(transactionData))

    @defer.inlineCallbacks
    def test_routeSmsGateway(self):
        request = yield self.web.post("sms-gateway/route-sms",
                                      {"destination": "+255718008164,+255729891801"})
        self.assertEquals(request.responseCode, 200)
        the_page = "".join(request.written)
        self.assertEquals("1701|255718008164" in the_page, True)
        self.assertEquals("1701|255729891801" in the_page, True)


    @defer.inlineCallbacks
    def test_twilioSmsGateway(self):
        request = yield self.web.post("sms-gateway/twilio")
        self.assertEquals(request.responseCode, 200)
        the_page = "".join(request.written)
        self.assertEquals(the_page, "Some(Twiml)")

    @defer.inlineCallbacks
    def test_voiceRequest(self):
        request = yield self.web.post("test/voice")
        self.assertEquals(request.responseCode, 200)
        the_page = "".join(request.written)
        self.assertEquals(the_page, """<?xml version="1.0" encoding="UTF-8"?><Response><Dial phoneNumbers="+254718008164"/></Response>""")
コード例 #2
0
class WebTest(unittest.TestCase):
    def setUp(self):
        self.web = DummySite(MainPage())

    @inlineCallbacks
    def test_get(self):
        response = yield self.web.get("childpage")
        self.assertEqual(response.value(), "hello")

    # if you have params / headers:
    response = yield self.web.get("childpage", {'paramone': 'value'}, {'referer': "http://somesite.com"})
コード例 #3
0
    def setUp(self):
        # Instanciate a RouterPB (a requirement for HTTPApi)
        RouterPBConfigInstance = RouterPBConfig()
        self.RouterPB_f = RouterPB()
        self.RouterPB_f.setConfig(RouterPBConfigInstance)
        
        # Provision Router with User and Route
        self.u1 = User(1, Group(1), 'fourat', 'correct')
        self.RouterPB_f.users.append(self.u1)
        self.RouterPB_f.mt_routing_table.add(DefaultRoute(SmppClientConnector('abc')), 0)

        # Instanciate a SMPPClientManagerPB (a requirement for HTTPApi)
        SMPPClientPBConfigInstance = SMPPClientPBConfig()
        SMPPClientPBConfigInstance.authentication = False
        clientManager_f = SMPPClientManagerPB()
        clientManager_f.setConfig(SMPPClientPBConfigInstance)
        
        httpApiConfigInstance = HTTPApiConfig()
        self.web = DummySite(HTTPApi(self.RouterPB_f, clientManager_f, httpApiConfigInstance))
コード例 #4
0
 def setUp(self):
     self.web = DummySite(MainPage())
コード例 #5
0
 def setUp(self):
     self.dlrProcessor = DlrProcessor()
     self.web          = DummySite(ATStagingWebResource(self.dlrProcessor))