X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=app%2Ftests%2Futils.py;h=be2b8690fa708725276dc13e0a37d0dd9c9f3c8d;hb=c1b4256d440d0c858dedb4971f96c78677538b1d;hp=782bb1de62e706421e6fde7d5e2f8ed6df390c6d;hpb=fd6ba459f928d110d796cd464b16f47f97dc0f53;p=cheatdb.git diff --git a/app/tests/utils.py b/app/tests/utils.py index 782bb1d..be2b869 100644 --- a/app/tests/utils.py +++ b/app/tests/utils.py @@ -1,4 +1,4 @@ -import pytest +import pytest, json from app import app from app.models import db, User from app.default_data import populate @@ -16,6 +16,21 @@ def recreate_db(): populate(db.session) db.session.commit() +def parse_json(b): + return json.loads(b.decode("utf8")) + +def is_type(t, v): + return v and isinstance(v, t) + +def is_optional(t, v): + return not v or isinstance(v, t) + +def is_str(v): + return is_type(str, v) + +def is_int(v): + return is_type(int, v) + @pytest.fixture def client():