Skip to content

Commit

Permalink
Add test for Item model
Browse files Browse the repository at this point in the history
  • Loading branch information
thatnerdjosh committed Sep 20, 2020
1 parent 44156b4 commit 17f207b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest
import json
from pydantic import ValidationError
from {{cookiecutter.app}}.services.items.model import Items

def test_create_item():
with open("fixtures/item.json") as item_json_file:
item_json = json.load(item_json_file)
try:
item = Items(**item_json)
except ValidationError as error:
err_str = ""
for err_obj in error.errors():
err_str += "{} gave error {}\r\n".format(err_obj["loc"][0], err_obj["msg"])
pytest.fail(err_str)

0 comments on commit 17f207b

Please sign in to comment.