def test_fetch_first(self): with requests_mock.mock() as mock: mock.get(client.get_full_url("data/persons"), text=json.dumps([{ "first_name": "John" }, { "first_name": "Jane" }])) self.assertEquals(client.fetch_first("persons"), {"first_name": "John"}) mock.get(client.get_full_url("data/persons"), text=json.dumps([])) self.assertIsNone(client.fetch_first("persons"))
def test_query_string(self): with requests_mock.mock() as mock: mock.get( raw.get_full_url("data/projects?name=Test"), text=json.dumps([{"name": "Project"}]), ) self.assertEqual( raw.fetch_first("projects", {"name": "Test"}), {"name": "Project"}, ) mock.get(raw.get_full_url("data/persons"), text=json.dumps([])) self.assertIsNone(raw.fetch_first("persons"))