def test_create_post_with_missing_data(db_connection, event_loop, test_client, cookies_fixture): category = event_loop.run_until_complete(CategoryFactory.create()) response = test_client.post('/admin/blog', cookies=cookies_fixture, data={ 'body': 'test body', 'category_id': category.id }) assert response.status_code == 400 assert '<p>title is obligatory</p>' in response.text
def test_create_post(db_connection, event_loop, test_client, cookies_fixture): category = event_loop.run_until_complete(CategoryFactory.create()) response = test_client.post('/admin/blog', cookies=cookies_fixture, data={ 'title': 'test title', 'body': 'test body', 'category_id': category.id, 'description': 'test description' }) assert response.status_code == 201 assert '<p>post created successfully</p>' in response.text
def test_category(graph_client): query = ''' query($id: ID!) { category(id: $id) { name description } } ''' category = CategoryFactory.create() result = graph_client.execute(query, variable_values={'id': model_instance_id_to_base64(category)}) assert result == { 'data': { 'category': { 'name': category.name, 'description': category.description } } }