Ejemplo n.º 1
0
 def test_get_requests(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     r = requests.get(location)
     self.assertEquals(r.status_code, 200)
     self.assertEquals(r.text, "Hello")
Ejemplo n.º 2
0
 def test_complete(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     msg, location = c.dequeue(Q)
     with self.assertRaises(RuntimeError):
         c.complete(*location.split('/')[-2:])
Ejemplo n.º 3
0
 def test_dequeue(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     c.enqueue(Q, "Hello")
     msg, location = c.dequeue(Q)
     self.assertEquals(msg, "Hello")
     self.assertTrue(location.startswith(c.queue_url(Q)))
Ejemplo n.º 4
0
 def test_complete_by_url_bad_input(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     c.dequeue(Q, timeout=1)
     with self.assertRaises(ValueError):
         c.complete_by_url('http://localhost:1111/q')
Ejemplo n.º 5
0
 def test_complete_by_url_mismatch(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     c.dequeue(Q, timeout=1)
     with self.assertRaises(RuntimeError):
         c.complete_by_url('http://localhost:1111/q/123')
Ejemplo n.º 6
0
 def test_complete_by_url(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     msg, location = c.dequeue(Q)
     with self.assertRaises(RuntimeError):
         c.complete_by_url(location)
Ejemplo n.º 7
0
 def test_enqueue(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     self.assertTrue(location.startswith(c.queue_url(Q)))
     _, _ = c.dequeue(Q)
     self.assertEquals(c.stats(Q), {
         u'timeouts': 0,
         u'depth': 0,
         u'enqueued': 1,
         u'dequeued': 1
     })
Ejemplo n.º 8
0
 def test_dequeue_timeout_expire(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     c.enqueue(Q, "Hello")
     msg, location = c.dequeue(Q, timeout=1)
     self.assertEquals(msg, "Hello")
     self.assertTrue(location.startswith(c.queue_url(Q)))
     id = location.split('/')[-1]
     self.assertEquals(c.stats(Q), {
         u'timeouts': 0,
         u'depth': 0,
         u'enqueued': 1,
         u'dequeued': 1
     })
     time.sleep(1.1)
     self.assertEquals(c.stats(Q), {
         u'timeouts': 1,
         u'depth': 1,
         u'enqueued': 2,
         u'dequeued': 1
     })
Ejemplo n.º 9
0
 def test_get(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     location = c.enqueue(Q, "Hello")
     id = location.split('/')[-1]
     self.assertEquals(c.get(Q, id), "Hello")
Ejemplo n.º 10
0
 def test_dequeue_wait(self):
     Q = random_queue_name()
     c = pyqueued.Client()
     with self.assertRaises(RuntimeError):
         msg, location = c.dequeue(Q, wait=0.2)
Ejemplo n.º 11
0
 def test_init(self):
     c = pyqueued.Client()
     self.assertTrue(c is not None)