def test_mock_form(): data = { 'method': 'PUT', 'path': '/v1/users/', 'request': { 'body': { 'name': 'John Doe' }, 'headers': { 'content_type': 'application/json', 'accept': 'application/json' } }, 'response': { 'body': { 'name': 'John Doe' }, 'headers': { 'content_type': 'application/json', 'accept': 'application/json' }, 'status_code': 201, } } form = MockForm(data=data) assert form.validate()
def __init__(self, expectation, host=None, port=None, docker=False): form = MockForm(data=expectation) if not form.validate(): raise ValidationError(form.errors) self.expectation = expectation self.host = host or config("ECHOD_API_HOST", default="127.0.0.1") self.port = port or config("ECHOD_API_PORT", default=9876) self.base_url = "http://{}:{}".format(self.host, self.port) self._session = requests.Session() self._urls = { "health": url_path_join(self.base_url, "health", "/"), "mocks": url_path_join(self.base_url, "mocks", "/"), "response": None, } self.mock_url = None