Esempio n. 1
0
    def test_requests_raise(self, post):

        """Verify that requests exceptions are raised to caller."""

        with self.assertRaises(RequestException):
            post.side_effect = RequestException
            Authenticator.generate_token('*****@*****.**','password','tag')
Esempio n. 2
0
    def test_auth_exception(self, post):

        """Verify that response 403 raises AuthException."""

        with self.assertRaises(AuthException):
            post.return_value.status_code = 403
            Authenticator.generate_token('*****@*****.**','password','tag')
Esempio n. 3
0
    def test_auth_exception(self):

        """Verify that response 403 raises AuthException."""

        with patch.object(requests, 'post') as mock_method:
            with self.assertRaises(AuthException):
                mock_method.return_value.status_code = 403
                Authenticator.generate_token('*****@*****.**','password','tag')
Esempio n. 4
0
    def test_requests_raise(self):

        """Verify that requests exceptions are raised to caller."""

        with patch.object(requests, 'post') as mock_method:
            with self.assertRaises(RequestException):
                mock_method.side_effect = RequestException
                Authenticator.generate_token('*****@*****.**','password','tag')
Esempio n. 5
0
    def test_parse_exception(self, post):
        """
        Verify that a ParseException is raised if the response body doesn't
        match the expected format.
        """

        with self.assertRaises(ParseException):
            post.return_value.status_code = 200
            post.return_value.content = 'loremipsum'
            Authenticator.generate_token('*****@*****.**', 'password', 'tag')
Esempio n. 6
0
    def test_parse_exception(self, post):

        """
        Verify that a ParseException is raised if the response body doesn't
        match the expected format.
        """

        with self.assertRaises(ParseException):
            post.return_value.status_code = 200
            post.return_value.content = 'loremipsum'
            Authenticator.generate_token('*****@*****.**','password','tag')
Esempio n. 7
0
    def test_auth_exception(self, post):
        """Verify that response 403 raises AuthException."""

        with self.assertRaises(AuthException):
            post.return_value.status_code = 403
            Authenticator.generate_token('*****@*****.**', 'password', 'tag')
Esempio n. 8
0
    def test_requests_raise(self, post):
        """Verify that requests exceptions are raised to caller."""

        with self.assertRaises(RequestException):
            post.side_effect = RequestException
            Authenticator.generate_token('*****@*****.**', 'password', 'tag')