diff options
author | rubenwardy <rw@rubenwardy.com> | 2020-01-19 19:09:04 +0000 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2020-01-19 19:09:04 +0000 |
commit | 0bda16de6dae7a684acf4332312765fe2d78741c (patch) | |
tree | 86d19c95f391af2b2897ca3d4a307878b09fc065 /app/tests/utils.py | |
parent | fd6ba459f928d110d796cd464b16f47f97dc0f53 (diff) | |
download | cheatdb-0bda16de6dae7a684acf4332312765fe2d78741c.tar.xz |
Add API tests
Diffstat (limited to 'app/tests/utils.py')
-rw-r--r-- | app/tests/utils.py | 17 |
1 files changed, 16 insertions, 1 deletions
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(): |