def test_get_token_method_checks_no_authorization(self): with self.assertRaises(Exception) as e: class requestObject: headers = {} Auth.get_token(request_obj=requestObject) self.assertEqual(e.exception.args[0], 'Authorization Header is Expected')
def test_get_token_return_token_if_valid_header_present(self): with self.app.test_request_context(path='/api/v1/vendors', method='GET', headers=self.headers()) as request: token = Auth.get_token() self.assertIsInstance(token, str) self.assertIsNotNone(token)
def test_get_token_throws_exception_when_auth_header_missing(self): try: Auth.get_token() assert False except Exception as e: assert True