Merge pull request #2269 from coreos-inc/test-queue-delete-check
test(queue): delete_namespaced_items
This commit is contained in:
commit
e27db5ada4
1 changed files with 44 additions and 0 deletions
|
@ -244,5 +244,49 @@ class TestQueue(QueueTestCase):
|
|||
count = self.queue.num_available_jobs_between(now, now, 'abc')
|
||||
self.assertEqual(0, count)
|
||||
|
||||
def test_deleted_namespaced_items(self):
|
||||
self.queue = AutoUpdatingQueue(WorkQueue(QUEUE_NAME, self.transaction_factory,
|
||||
reporter=self.reporter,
|
||||
has_namespace=True))
|
||||
|
||||
self.queue.put(['somenamespace', 'abc', 'def'], self.TEST_MESSAGE_1, available_after=-10)
|
||||
self.queue.put(['somenamespace', 'abc', 'ghi'], self.TEST_MESSAGE_2, available_after=-5)
|
||||
self.queue.put(['anothernamespace', 'abc', 'def'], self.TEST_MESSAGE_1, available_after=-10)
|
||||
|
||||
# Ensure we have 2 items under `somenamespace` and 1 item under `anothernamespace`.
|
||||
now = datetime.utcnow()
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/somenamespace'])
|
||||
self.assertEqual(2, count)
|
||||
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/anothernamespace'])
|
||||
self.assertEqual(1, count)
|
||||
|
||||
# Delete all `somenamespace` items.
|
||||
self.queue.delete_namespaced_items('somenamespace')
|
||||
|
||||
# Check the updated counts.
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/somenamespace'])
|
||||
self.assertEqual(0, count)
|
||||
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/anothernamespace'])
|
||||
self.assertEqual(1, count)
|
||||
|
||||
# Delete all `anothernamespace` items.
|
||||
self.queue.delete_namespaced_items('anothernamespace')
|
||||
|
||||
# Check the updated counts.
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/somenamespace'])
|
||||
self.assertEqual(0, count)
|
||||
|
||||
count = self.queue.num_available_jobs_between(now - timedelta(seconds=60), now,
|
||||
['/anothernamespace'])
|
||||
self.assertEqual(0, count)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Reference in a new issue