# CRUD Cookies import pytest from apistar import TestClient from cookie_api.models import Cookie from cookie_api.app import get_cookies, get_cookie def test_get_cookies_empty(app): client = TestClient(app) response = client.get('/cookies') assert response.status_code == 200 assert response.json() == [] def test_get_empty_cookies(rb_session): assert [] == get_cookies(rb_session) def test_get_cookies(rb_session): cookie = Cookie(name='sugar', recipe_url='http://cookie.com/sugar', sku='SC', qoh=14, unit_cost=1.50) rb_session.add(cookie) rb_session.flush() cookies = rb_session.query(Cookie).all() assert [cookie.to_dict() for cookie in cookies] == get_cookies(rb_session) def test_get_cookie(rb_session): cookie = Cookie(name='sugar', recipe_url='http://cookie.com/sugar', sku='SC', qoh=14, unit_cost=1.50) rb_session.add(cookie) rb_session.flush() cookie = rb_session.query(Cookie).filter_by(id=cookie.id).one() assert cookie.to_dict() == get_cookie(rb_session, 1) def test_get_cookie_that_doesnt_exist(rb_session): response = get_cookie(rb_session, 100) assert {"error": "404 Not Found"} == response.content assert 404 == response.status @pytest.mark.skip() def test_valid_create_cookie(): pass @pytest.mark.skip() def test_invalid_create_cookie(): pass @pytest.mark.skip() def test_valid_update_cookie(): pass @pytest.mark.skip() def test_invalid_update_cookie(): pass @pytest.mark.skip() def test_delete_cookie(): pass