-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functional test for delete collection then post scenario #62
base: master
Are you sure you want to change the base?
Changes from 2 commits
ea76138
8848a6a
e3f9bc5
b8d6cd4
38703f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -574,6 +574,63 @@ def test_delete_collection_items(self): | |
res = self.app.get(self.root + '/storage/col2') | ||
self.assertEquals(len(res.json), 0) | ||
|
||
def test_delete_collection_then_post(self): | ||
# creating a collection of three | ||
bso1 = {'id': '12', 'payload': _PLD} | ||
bso2 = {'id': '13', 'payload': _PLD} | ||
bso3 = {'id': '14', 'payload': _PLD} | ||
bsos = [bso1, bso2, bso3] | ||
|
||
self.app.post_json(self.root + '/storage/col2', bsos) | ||
res = self.app.get(self.root + '/storage/col2') | ||
self.assertEquals(len(res.json), 3) | ||
|
||
resp = self.app.get(self.root + '/info/collections') | ||
res = resp.json | ||
self.assertTrue("col2" in res) | ||
|
||
infoBefore = self.app.get(self.root + '/info/collections') | ||
|
||
# Deleting the collection should result in: | ||
# - collection does not appear in /info/collections | ||
# - X-Last-Modified timestamp at the storage level changing | ||
self.app.delete(self.root + '/storage/col2') | ||
items = self.app.get(self.root + '/storage/col2').json | ||
self.assertEquals(len(items), 0) | ||
|
||
infoAfter1 = self.app.get(self.root + '/info/collections') | ||
res = infoAfter1.json | ||
self.assertTrue("col2" not in res) | ||
self.assertTrue("X-Last-Modified" in resp.headers) | ||
self.assertNotEqual(infoBefore.headers["X-Last-Modified"], | ||
infoAfter1.headers["X-Last-Modified"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to assert that after is greater than before, not just that they're unequal. |
||
|
||
# make sure the storage level timestamp stays the same | ||
time.sleep(0.2) | ||
infoAfter2 = self.app.get(self.root + '/info/collections') | ||
self.assertEqual(infoAfter1.headers["X-Last-Modified"], | ||
infoAfter2.headers["X-Last-Modified"]) | ||
|
||
# post BSOs again with X-I-U-S == 0 | ||
self.app.post_json( | ||
self.root + '/storage/col2', bsos, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This could fit on the previous line |
||
headers=[('X-If-Unmodified-Since', "0.00")]) | ||
infoAfter3 = self.app.get(self.root + '/info/collections') | ||
self.assertNotEqual(infoAfter3.headers["X-Last-Modified"], | ||
infoAfter2.headers["X-Last-Modified"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here re: greater-than |
||
|
||
# delete and POST again with X-I-U-S > 0 | ||
self.app.delete(self.root + '/storage/col2') | ||
items = self.app.get(self.root + '/storage/col2').json | ||
self.assertEquals(len(items), 0) | ||
self.app.post_json( | ||
self.root + '/storage/col2', bsos, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This could fit on the previous line |
||
headers=[('X-If-Unmodified-Since', "1.00")]) | ||
|
||
infoAfter4 = self.app.get(self.root + '/info/collections') | ||
self.assertNotEqual(infoAfter4.headers["X-Last-Modified"], | ||
infoAfter3.headers["X-Last-Modified"]) | ||
|
||
def test_delete_item(self): | ||
# creating a collection of three | ||
bso1 = {'id': '12', 'payload': _PLD} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different from the previous resp on L588?