Example #1
0
 def test_init_without_email(self):
     # Un-set the token now and make sure the init fails
     librato.EMAIL = None
     with self.assertRaises(exceptions.InvalidCredentials):
         librato.Annotation('Unit Test Action', {
             'title': 'unittest',
             'description': 'unittest',
             'name': 'unittest'
         })
Example #2
0
    def integration_test_execute(self):
        actor = librato.Annotation(
            'Unit Test Action', {
                'title': 'Kingpin Integration Testing',
                'description': 'Executing integration tests',
                'name': 'kingpin-integration-testing'
            })

        res = yield actor.execute()
        self.assertEqual(res, None)
Example #3
0
 def integration_test_init_without_token(self):
     # Un-set auth token and make sure the init fails
     librato.TOKEN = None
     with self.assertRaises(exceptions.InvalidCredentials):
         librato.Annotation('Unit Test Action', {
             'title': 'unittest',
             'description': 'unittest',
             'name': 'unittest'
         },
                            dry=True)
Example #4
0
    def integration_test_execute_with_invalid_email(self):
        # Set auth email to invalid value and make sure execute fails
        librato.EMAIL = 'Invalid'

        actor = librato.Annotation('Unit Test Action', {
            'title': 'unittest',
            'description': 'unittest',
            'name': 'unittest'
        },
                                   dry=True)

        with self.assertRaises(exceptions.InvalidCredentials):
            yield actor.execute()
Example #5
0
    def test_execute_with_unknown_exception(self):
        actor = librato.Annotation('Unit Test Action', {
            'title': 'unittest',
            'description': 'unittest',
            'name': 'unittest'
        })

        http_response = httpclient.HTTPError(code=123, response={})

        with mock.patch.object(actor, '_get_http_client') as m:
            m.return_value = FakeExceptionRaisingHTTPClientClass()
            m.return_value.response_value = http_response

            with self.assertRaises(httpclient.HTTPError):
                yield actor._execute()
Example #6
0
    def test_execute(self):
        actor = librato.Annotation('Unit Test Action', {
            'title': 'unittest',
            'description': 'unittest',
            'name': 'unittest'
        })

        response_dict = {'status': 'sent'}
        response_body = json.dumps(response_dict)
        http_response = httpclient.HTTPResponse(
            httpclient.HTTPRequest('/'),
            code=200,
            buffer=StringIO.StringIO(response_body))

        with mock.patch.object(actor, '_get_http_client') as m:
            m.return_value = FakeHTTPClientClass()
            m.return_value.response_value = http_response
            res = yield actor._execute()
            self.assertEquals(res, None)