Merge pull request #2269 from coreos-inc/test-queue-delete-check

test(queue): delete_namespaced_items
This commit is contained in:
josephschorr 2017-01-09 11:21:53 -05:00 committed by GitHub
commit e27db5ada4

View file

@ -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()