Пример #1
0
    def test_no_record_in_db_device_channel_info(self):
        message_request, message_response = self.get_message()
        dci = DeviceChannelInfo.objects.get(pk=message_request._id)
        dci.delete()

        with self.assertRaises(ObjectDoesNotExist):
            tasks.send_message(message_request, message_response)
Пример #2
0
    def test_http_resonse_200_fail_MissingCollapseKey(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="  Error =MissingCollapseKey ")

        with self.assertRaises(MissingCollapseKeyException):
            tasks.send_message(*self.get_message())
Пример #3
0
    def test_http_resonse_200_fail_UnknownCodeXX(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="  Error =UnknownCodeXX ")

        with self.assertRaises(UnknownErrorCodeException):
            tasks.send_message(*self.get_message())
Пример #4
0
    def test_http_resonse_200_fail_DeviceQuotaExceeded(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="  Error =DeviceQuotaExceeded ")

        with self.assertRaises(DeviceQuotaExceededException):
            tasks.send_message(*self.get_message())
Пример #5
0
    def test_http_resonse_200_fail_MessageTooBig(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="  Error =MessageTooBig ")

        with self.assertRaises(MessageTooBigException):
            tasks.send_message(*self.get_message())
Пример #6
0
    def test_http_resonse_200_fail_NotRegistered(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="  Error =   NotRegistered ")

        with self.assertRaises(NotRegisteredException):
            tasks.send_message(*self.get_message())
Пример #7
0
    def test_http_resonse_200_fail_InvalidRegistration(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response="Error=InvalidRegistration")

        with self.assertRaises(InvalidRegistrationException):
            tasks.send_message(*self.get_message())
Пример #8
0
    def test_http_resonse_401_fail_InvalidAuthToken(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(code=401)

        with self.assertRaises(ErrorInvalidAuthTokenException):
            tasks.send_message(*self.get_message())
Пример #9
0
    def test_http_resonse_503_fail(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(code=503)

        with self.assertRaises(RetryTaskError):
            tasks.send_message(*self.get_message())
Пример #10
0
    def test_failed_push_in_db(self):
        message_request, message_response = self.get_message()
        dci = DeviceChannelInfo.objects.get(pk=message_request._id)
        dci.device.failed_push = True
        dci.device.save()

        with self.assertRaises(FailedPushException):
            tasks.send_message(message_request, message_response)
Пример #11
0
    def test_http_resonse_200_success(self):
        tasks.urllib2.urlopen = make_fake_urlopen()

        tasks.urllib2.urlopen = make_fake_urlopen(response=" id  =   123  ")
        response = tasks.send_message(*self.get_message())
        self.assertEqual(response, "123")