def test_get_empty(self): queue = Mock(name='test-queue') url = 'test-url' # test reader = Reader(queue, url=url) reader.receiver = Mock() reader.receiver.fetch.side_effect = Empty message = reader.get(10) # validation reader.receiver.fetch.assert_called_once_with(10) self.assertEqual(message, None)
def test_get(self): queue = Mock(name='test-queue') received = Mock(content='<body/>') url = 'test-url' # test reader = Reader(queue, url=url) reader.receiver = Mock() reader.receiver.fetch.return_value = received message = reader.get(10) # validation reader.receiver.fetch.assert_called_once_with(10) self.assertTrue(isinstance(message, Message)) self.assertEqual(message._reader, reader) self.assertEqual(message._impl, received) self.assertEqual(message._body, received.body)