def test_deserialize_complete(self): route = Route.deserialize({ 'id': 'id1', 'path': '/endpoint_\\w*', 'method': 'GET', 'auth': { 'method': 'basic', 'username': '******', 'password': '******' }, 'response_selection': 'random', 'responses': [ { 'id': 'response_1', 'body': { 'works': True } } ] }) assert route.id == 'id1' assert isinstance(route.path, re.Pattern) assert route.method == 'GET' assert route.auth.method == 'basic' assert route.response_selection == ResponseSelectionStrategy.random assert route.is_active == True
def test_deserialize_duplicate_response_ids(self): with pytest.raises(RouteConfigurationError): route = Route.deserialize({ 'id': 'id1', 'path': '/endpoint_\\w*', 'responses': [ { 'id': 'duplicate', 'body': '' }, { 'id': 'duplicate', 'body': '' } ] })
def test_deserialize_minimal(self): route = Route.deserialize({ 'id': 'id1', 'path': '/endpoint_\\w*', 'responses': [ { 'body': '' } ] }) assert route.id == 'id1' assert isinstance(route.path, re.Pattern) assert route.method == 'GET' assert isinstance(route.auth, NoAuth) assert route.response_selection == ResponseSelectionStrategy.greedy assert route.is_active == True