-
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
Open
mostlygeek
wants to merge
5
commits into
master
Choose a base branch
from
improve-col-delete-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea76138
Add functional test for delete collection then post scenario
mostlygeek 8848a6a
fix flake8 errors
mostlygeek e3f9bc5
@natim review.
b8d6cd4
improve testing logic for collection deletion
mostlygeek 38703f4
fix merge conflict
mostlygeek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
infoBefore = self.app.get(self.root + '/info/collections') | ||
res = infoBefore.json | ||
self.assertTrue("col2" in res) | ||
|
||
# make sure the storage level timestamp changes | ||
time.sleep(0.2) | ||
|
||
# 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 infoBefore.headers) | ||
self.assertTrue("X-Last-Modified" in infoAfter1.headers) | ||
self.assertNotEqual(infoBefore.headers["X-Last-Modified"], | ||
infoAfter1.headers["X-Last-Modified"]) | ||
|
||
# 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, | ||
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, | ||
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} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should be able to assert that after is greater than before, not just that they're unequal.