diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-20 14:40:22 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-20 14:40:22 -0700 |
commit | 064a68bfd8ede79c3927ab3a9d9507d5716d8154 (patch) | |
tree | 95f01f3648c19085774f3fb5b5a8a3f813551ca3 /tests/test_backend.py | |
parent | 35b2d8a7589906f699c75bc52242bf362d37e427 (diff) | |
download | fatcat-064a68bfd8ede79c3927ab3a9d9507d5716d8154.tar.gz fatcat-064a68bfd8ede79c3927ab3a9d9507d5716d8154.zip |
check for (and fix) API relations
Diffstat (limited to 'tests/test_backend.py')
-rw-r--r-- | tests/test_backend.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/test_backend.py b/tests/test_backend.py index 373cceb9..25421560 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -240,10 +240,9 @@ class APITestCase(FatcatTestCase): data=json.dumps(dict( title="dummy work", work_type="book", - # XXX: - #work=work_id, - #container=container_id, - #creators=[creator_id], + work=work_id, + container=container_id, + creators=[creator_id], doi="10.1234/5678", editgroup=editgroup_id, refs=[ @@ -259,12 +258,13 @@ class APITestCase(FatcatTestCase): data=json.dumps(dict( sha1="deadbeefdeadbeef", size=1234, - release=release_id, + releases=[release_id], editgroup=editgroup_id, extra=dict(f=4, b="zing"))), headers={"content-type": "application/json"}) assert rv.status_code == 200 obj = json.loads(rv.data.decode('utf-8')) + file_id = obj['id'] for cls in (WorkIdent, WorkRev, WorkEdit, ContainerIdent, ContainerRev, ContainerEdit, @@ -299,4 +299,13 @@ class APITestCase(FatcatTestCase): FileIdent): assert cls.query.filter(cls.is_live==True).count() == 1 - # XXX: re-fetch and test that relations work + # Test that foreign key relations worked + release_rv = json.loads(self.app.get('/v0/release/{}'.format(release_id)).data.decode('utf-8')) + print(release_rv) + assert(release_rv['creators'][0]['creator'] == creator_id) + assert(release_rv['container']['id'] == container_id) + assert(release_rv['work']['id'] == work_id) + + file_rv = json.loads(self.app.get('/v0/file/{}'.format(file_id)).data.decode('utf-8')) + print(file_rv) + assert(file_rv['releases'][0]['release'] == release_id) |