Esempio n. 1
0
    def test_dequeue(self, response):
        response.return_value = {'item': {'val': 'bazz'}}, 201
        queue = Queue(self.Queues, 'foo')
        item = queue.dequeue()
        response.assert_called_with(
            'http://localhost:8000/api/Queues/foo/Dequeue', data={})
        self.assertEqual({'val': 'bazz'}, item)

        self.assertIsNotNone(
            queue)  # make sure we still have reference to the instance
Esempio n. 2
0
    def test_dequeue(self, response):
        response.return_value = {
            'item': {
                'val': 'bazz'
            }
        }, 201
        queue = Queue(self.Queues, 'foo')
        item = queue.dequeue()
        response.assert_called_with('http://localhost:8000/api/Queues/foo/Dequeue', data={})
        self.assertEqual({
            'val': 'bazz'
        }, item)

        self.assertIsNotNone(queue)  # make sure we still have reference to the instance
class EmailQueue(object):
    def __init__(self, siphon_client, queue_name):
        self.client = siphon_client
        self.queue_name = queue_name
        self.emails = Queue(self.client.Queues, self.queue_name)
    
    def fetch_email(self):
        email = self._siphon_dequeue()
        template = email.pop('template', None)
        return Email(template, **email)
    
    def _siphon_dequeue(self):
        return self.emails.dequeue()
 def __init__(self, siphon_client, queue_name):
     self.client = siphon_client
     self.queue_name = queue_name
     self.emails = Queue(self.client.Queues, self.queue_name)