Пример #1
0
 def test_get_groups(self, mock_request):
     groups = ['group1', 'group2']
     response = mock.MagicMock(status_code=200)
     response.json.return_value = groups
     mock_request.return_value = response
     client = CandidClient()
     self.assertEqual(client.get_groups('foo'), groups)
     mock_request.assert_called_with(
         'GET',
         'https://auth.example.com/v1/u/foo/groups',
         auth=mock.ANY,
         cookies=mock.ANY,
         json=None)
Пример #2
0
 def test_get_groups_user_not_found(self, mock_request):
     response = mock.MagicMock(status_code=404)
     response.json.return_value = {
         'code': 'not found',
         'messsage': 'user foo not found'
     }
     mock_request.return_value = response
     client = CandidClient()
     self.assertRaises(APIError, client.get_groups, 'foo')
Пример #3
0
 def test_get_groups_user_not_found(self, mock_request):
     response = mock.MagicMock(status_code=404)
     response.json.return_value = {
         "code": "not found",
         "messsage": "user foo not found",
     }
     mock_request.return_value = response
     client = CandidClient()
     self.assertRaises(APIError, client.get_groups, "foo")