Ejemplo n.º 1
0
class SimpleQueueTests(unittest.TestCase):

    def setUp(self):
        self.config = MagicMock()
        modules = {'config': self.config}
        self.module_patcher = patch.dict('sys.modules', modules)
        self.module_patcher.start()
        from recrawler.simplequeue import Queue
        self.simplequeue = Queue()

    def tearDown(self):
        self.module_patcher.stop()

    def test_getall(self):
        self.simplequeue.q = [1, 2, 3]
        result = self.simplequeue.getall()
        self.assertEqual(result, [1, 2, 3])

    def test_pack(self):
        result = self.simplequeue.pack('http://hulahoop.com', test='hoho')
        self.assertEqual(result, {'url': 'http://hulahoop.com',
                                  'test': 'hoho'})