diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-20 16:12:20 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-20 16:17:48 -0700 |
commit | cc85fa69262b6e937e9d675808ca779d15c6fd85 (patch) | |
tree | 1ed07b144819f39da895ae088fd78c75b77237d2 /tests/fixtures.py | |
parent | 5fa778fcf771b2512844e43e19e5785260ee0452 (diff) | |
download | fatcat-cc85fa69262b6e937e9d675808ca779d15c6fd85.tar.gz fatcat-cc85fa69262b6e937e9d675808ca779d15c6fd85.zip |
refactor tests around more
Diffstat (limited to 'tests/fixtures.py')
-rw-r--r-- | tests/fixtures.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/fixtures.py b/tests/fixtures.py new file mode 100644 index 00000000..9176b8c5 --- /dev/null +++ b/tests/fixtures.py @@ -0,0 +1,57 @@ + +import pytest +import fatcat +import fatcat.sql +from fatcat.models import * + + +@pytest.fixture +def app(): + fatcat.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' + fatcat.app.testing = True + fatcat.app.debug = True + fatcat.db.session.remove() + fatcat.db.drop_all() + fatcat.db.create_all() + fatcat.sql.populate_db() + return fatcat.app.test_client() + +@pytest.fixture +def rich_app(app): + assert app.post('/v0/work', + data=json.dumps(dict( + title="dummy", + work_type="thing", + extra=dict(a=1, b="zing"))), + headers={"content-type": "application/json"} + ).status_code == 200 + return app + + +## Helpers ################################################################## + +def check_entity_fields(e): + for key in ('rev', 'is_live', 'redirect_id'): + assert key in e + for key in ('id',): + assert e[key] is not None + +def check_release(e): + for key in ('work', 'release_type'): + assert key in e + for key in ('title'): + assert e[key] is not None + for key in ('refs', 'creators'): + assert type(e[key]) == list + +def check_creator(e): + for key in ('name',): + assert e[key] is not None + +def check_container(e): + for key in ('name',): + assert e[key] is not None + +def check_file(e): + for key in ('size', 'sha1'): + assert e[key] is not None |