Beispiel #1
0
    def test_create_general_failure_payload(self):
        service = self._create_service()
        self.assertIsNotNone(service)

        started = datetime.now()
        speed = timedelta(microseconds=3000)
        data = service._create_general_failure_payload(
            "test", "http://some.service.com", "GET", 3, started, speed,
            RESTServiceException("Something went wrong"))

        self.assertTrue('response' in data)
        self.assertEqual(data['response']['status'], "failure")
        self.assertEqual(data['response']['url'], "http://some.service.com")
        self.assertEqual(data['response']['call'], "GET")
        self.assertEqual(data['response']['retries'], 3)
        self.assertEqual(data['response']['started'],
                         started.strftime("%d/%m/%Y, %H:%M:%S"))
        self.assertEqual(data['response']['speed'], "3.0ms")
        self.assertEqual(data['response']['service'], "test")
        self.assertEqual(data['response']['category'], "category")

        self.assertTrue("payload" in data['response'])
        self.assertEqual(data['response']['payload']['type'], 'general')
        self.assertEqual(data['response']['payload']['error'],
                         "Something went wrong")
Beispiel #2
0
 def __init__(self, msg):
     RESTServiceException.__init__(self, msg)
Beispiel #3
0
 def test_init(self):
     exception = RESTServiceException("Service failed")
     self.assertIsNotNone(exception)
     self.assertEquals('Service failed', str(exception))