def test_calculate_time_to_reset(self): """Test whether the time to reset is zero if the sleep time is negative""" user = read_file('data/mattermost/mattermost_user_sduenas.json', 'rb') httpretty.register_uri(httpretty.GET, MATTERMOST_USER_SDUENAS, body=user, status=200, forcing_headers={ 'X-RateLimit-Remaining': '20', 'X-RateLimit-Reset': int(datetime_utcnow().replace(microsecond=0).timestamp()) }) client = MattermostClient('https://mattermost.example.com/', 'aaaa') _ = client.user('8tbwn7uikpdy3gpse6fgiie5co') time_to_reset = client.calculate_time_to_reset() self.assertEqual(time_to_reset, 0)
def test_user(self): """Test user API call""" http_requests = setup_http_server() client = MattermostClient('https://mattermost.example.com/', 'aaaa') # Call API user = client.user('8tbwn7uikpdy3gpse6fgiie5co') expected = [{}] self.assertEqual(len(http_requests), 1) for x in range(0, len(http_requests)): req = http_requests[x] self.assertEqual(req.method, 'GET') self.assertRegex(req.path, '/api/v4/users/8tbwn7uikpdy3gpse6fgiie5co') self.assertDictEqual(req.querystring, expected[x]) self.assertEqual(req.headers['Authorization'], 'Bearer aaaa')