Example #1
0
 def test_get(self):
     with requests_mock.mock() as mock:
         mock.get(
             raw.get_full_url("data/persons"),
             text='{"first_name": "John"}',
         )
         self.assertEqual(raw.get("data/persons"), {"first_name": "John"})
Example #2
0
 def test_get_two_clients(self):
     with requests_mock.mock() as mock:
         second_client = gazu.raw.create_client("http://second.host/api")
         mock.get(
             raw.get_full_url("data/persons"),
             text='{"first_name": "John"}',
         )
         self.assertEqual(raw.get("data/persons"), {"first_name": "John"})
         self.assertRaises(requests_mock.exceptions.NoMockAddress,
                           raw.get,
                           "data/persons",
                           client=second_client)
         mock.get(
             raw.get_full_url("data/persons", client=second_client),
             text='{"first_name": "John2"}',
         )
         self.assertEqual(
             raw.get("data/persons", client=second_client),
             {"first_name": "John2"},
         )