def test_delete_queue(self): request = Request(post={'token': 't', 'domain': 'x.com'}) queue = filter(None, views.new_queue(request)['queue'].split('/'))[-1] request = Request(params={'token': 't'}, matchdict={'queue': queue}) views.delete_queue(request) eq_(views.get_queues(Request(params={'token': 't'})), {})
def test_get_queues(self): token = views.new_token(Request())['token'] request = Request(post={'token': token, 'domain': 'domain'}) queue = views.new_queue(request)['queue'] request = Request(params={'token': token}) response = views.get_queues(request) eq_(response, {'domain': queue})
def test_new_queue(self): # A new queue should be available in storage. self.storage.new_token = lambda: 'new-queue' request = Request(post={'token': 't', 'domain': 'x.com'}) response = views.new_queue(request) eq_(response, {'queue': '/queue/new-queue/'}) assert self.storage.user_owns_queue('t', 'new-queue') eq_(self.storage.get_user_for_queue('new-queue'), 't')
def test_delete_queue_404(self): request = Request(post={'token': 't', 'domain': 'x.com'}) queue = filter(None, views.new_queue(request)['queue'].split('/'))[-1] # A valid token with an invalid queue gets a 404. request = Request(params={'token': 't'}, matchdict={'queue': 'x'}) eq_(views.delete_queue(request).code, 404) # An invalid token with a valid queue gets a 404. request = Request(params={'token': 'x'}, matchdict={'queue': queue}) eq_(views.delete_queue(request).code, 404)