You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cookie-api/tests/test_cookies.py

83 lines
1.9 KiB
Python

# CRUD Cookies
import pytest
import json
from apistar import TestClient
from cookie_api.models import Cookie
from cookie_api.resources.cookies import get_cookies, get_cookie
from cookie_api.util import ExtJSONResponse
def test_get_cookies_empty(app):
client = TestClient(app)
response = client.get('/cookies')
assert response.status_code == 200
assert response.json()['data'] == []
def test_get_empty_cookies(rb_session):
extended_response = get_cookies(rb_session)
assert extended_response.status_code == 200
assert extended_response._content == []
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()
extended_response = get_cookies(rb_session)
assert len(extended_response._content) == 1
@pytest.mark.skip()
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)
@pytest.mark.skip()
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