Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions syncstorage/tests/functional/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link

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?


# 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"])
Copy link
Contributor

Choose a reason for hiding this comment

The 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,
Copy link

Choose a reason for hiding this comment

The 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"])
Copy link
Contributor

Choose a reason for hiding this comment

The 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,
Copy link

Choose a reason for hiding this comment

The 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}
Expand Down