def test_direct_registration_with_multiple_methods(client: Fabricator, m: requests_mock.Mocker): # Add an endpoint using "register" client.register(name='update', path='/todos/:id', methods=['PUT', 'PATCH']) client.start() # Mock it m.request(requests_mock.ANY, '{}/todos/1'.format(BASE_URL), text='OK') def asrt(resp): assert resp.status_code is 200 assert m.last_request.json()['value'] == 'Thing to do' # Test it resp = client.update.put(id=1, value='Thing to do') asrt(resp) resp = client.update.patch(id=1, value='Thing to do') asrt(resp)
def test_collision_management(client: Fabricator, m: requests_mock.Mocker): # Register an endpoint that has the same name as one of the built ins client.get(name='register', path='/__health') client.start() # Mock the request m.get(HEALTH_TEST_URL, text='OK') # Call the endpoint resp = client.register() assert resp.status_code is 200 assert resp.text == 'OK'