def test_it_serves_recipes(self, client): recipe = RecipeFactory(arguments={'foo': 'bar'}) data = ClientParametersFactory() res = client.post('/api/v1/fetch_bundle/', data) action = recipe.action impl_url = reverse('recipes:action-implementation', kwargs={ 'name': action.name, 'impl_hash': action.implementation_hash, }) assert res.status_code == 200 assert res.data['recipes'] == [{ 'name': recipe.name, 'id': recipe.id, 'revision_id': recipe.revision_id, 'action': { 'name': action.name, 'implementation_url': Whatever.endswith(impl_url), 'arguments_schema': action.arguments_schema, }, 'arguments': { 'foo': 'bar', }, }]
def test_it_serves_actions(self, api_client): action = ActionFactory( name="foo", implementation="foobar", arguments_schema={"type": "object"} ) res = api_client.get("/api/v1/action/") action_url = reverse( "recipes:v1:action-implementation", kwargs={"name": action.name, "impl_hash": action.implementation_hash}, ) assert res.status_code == 200 assert res.data == [ { "name": "foo", "implementation_url": Whatever.endswith(action_url), "arguments_schema": {"type": "object"}, } ]
def test_it_serves_actions(self, api_client): action = ActionFactory(name='foo', implementation='foobar', arguments_schema={'type': 'object'}) res = api_client.get('/api/v1/action/') action_url = reverse('recipes:action-implementation', kwargs={ 'name': action.name, 'impl_hash': action.implementation_hash, }) assert res.status_code == 200 assert res.data == [{ 'name': 'foo', 'implementation_url': Whatever.endswith(action_url), 'arguments_schema': { 'type': 'object' } }]
def test_it_serves_actions(self, api_client): action = ActionFactory( name='foo', implementation='foobar', arguments_schema={'type': 'object'} ) res = api_client.get('/api/v1/action/') action_url = reverse('recipes:action-implementation', kwargs={ 'name': action.name, 'impl_hash': action.implementation_hash, }) assert res.status_code == 200 assert res.data == [ { 'name': 'foo', 'implementation_url': Whatever.endswith(action_url), 'arguments_schema': {'type': 'object'} } ]
def test_it_works(self, rf): recipe = RecipeFactory(arguments={'foo': 'bar'}) action = recipe.action serializer = RecipeSerializer(recipe, context={'request': rf.get('/')}) action_url = reverse('recipes:action-implementation', kwargs={ 'name': action.name, 'impl_hash': action.implementation_hash, }) assert serializer.data == { 'name': recipe.name, 'id': recipe.id, 'revision_id': recipe.revision_id, 'action': { 'name': action.name, 'implementation_url': Whatever.endswith(action_url), 'arguments_schema': action.arguments_schema, }, 'arguments': { 'foo': 'bar', } }