def test_get_wrong_items(self): """Test get_events API call""" HTTPServer.routes() # Set up a mock HTTP server body = read_file('data/remo/remo_events_page_1_2.json') client = ReMoClient(MOZILLA_REPS_SERVER_URL) with self.assertRaises(ValueError): _ = next(client.get_items(category='wrong'))
def test_get_items(self): """Test get_events API call""" HTTPServer.routes() # Set up a mock HTTP server body = read_file('data/remo/remo_events_page_1_2.json') client = ReMoClient(MOZILLA_REPS_SERVER_URL) response = next(client.get_items()) req = HTTPServer.requests_http[-1] self.assertEqual(response, body) self.assertEqual(req.method, 'GET') self.assertRegex(req.path, '/api/remo/v1/events/') self.assertDictEqual(req.querystring, {'page': ['1'], 'orderby': ['ASC']})
def test_call(self): """Test get_all_users API call""" HTTPServer.routes() # Set up a mock HTTP server body = read_file('data/remo/remo_events_page_1_2.json') client = ReMoClient(MOZILLA_REPS_SERVER_URL) response = client.fetch(MOZILLA_REPS_API + '/events/?page=1') req = HTTPServer.requests_http[-1] self.assertEqual(response, body) self.assertEqual(req.method, 'GET') self.assertEqual(req.path, '/api/remo/v1/events/?page=1') # Check request params expected = {'page': ['1']} self.assertDictEqual(req.querystring, expected)
def test_init(self): """Test initialization""" remo = ReMoClient(MOZILLA_REPS_SERVER_URL) self.assertEqual(remo.base_url, MOZILLA_REPS_SERVER_URL) self.assertIsNone(remo.archive) self.assertFalse(remo.from_archive) self.assertTrue(remo.ssl_verify) remo = ReMoClient(MOZILLA_REPS_SERVER_URL, ssl_verify=False) self.assertEqual(remo.base_url, MOZILLA_REPS_SERVER_URL) self.assertIsNone(remo.archive) self.assertFalse(remo.from_archive) self.assertFalse(remo.ssl_verify)
def test_init(self): """Test initialization""" client = ReMoClient(MOZILLA_REPS_SERVER_URL)