예제 #1
0
    def test_parse_booleannd_dt_epoch(self):
        self.assertTrue(HistoryMiddleware.parse_epoch('True'))
        self.assertFalse(HistoryMiddleware.parse_epoch('False'))
        self.assertTrue(HistoryMiddleware.parse_epoch(True))
        self.assertFalse(HistoryMiddleware.parse_epoch(False))

        some_dt = datetime.now()
        self.assertEqual(HistoryMiddleware.parse_epoch(some_dt), some_dt)
class TestHistoryMiddleware(unittest.TestCase):
    def setUp(self):
        self.middleware = HistoryMiddleware()

    def test_unconfigured_init(self):
        with self.assertRaises(NotConfigured):
            self.middleware = HistoryMiddleware(settings={})

    def test_parse_epoch(self):
        self.assertIsInstance(self.middleware.parse_epoch('yesterday'),
                              datetime)
class TestHistoryMiddleware(unittest.TestCase):

    def setUp(self):
        self.middleware = HistoryMiddleware()

    def test_unconfigured_init(self):
        with self.assertRaises(NotConfigured):
            self.middleware = HistoryMiddleware(settings={})

    def test_parse_epoch(self):
        self.assertIsInstance(
            self.middleware.parse_epoch('yesterday'),
            datetime)
예제 #4
0
class TestHistoryMiddleware(unittest.TestCase):

    def setUp(self):
        settings_dict = {k: 'mock setting' for k in MANDATORY_SETTINGS}
        crawler = get_crawler(settings_dict=settings_dict)
        self.middleware = HistoryMiddleware(crawler)

    def test_unconfigured_init(self):
        with self.assertRaises(NotConfigured):
            self.middleware = HistoryMiddleware(get_crawler())

    def test_parse_booleannd_dt_epoch(self):
        self.assertTrue(HistoryMiddleware.parse_epoch('True'))
        self.assertFalse(HistoryMiddleware.parse_epoch('False'))
        self.assertTrue(HistoryMiddleware.parse_epoch(True))
        self.assertFalse(HistoryMiddleware.parse_epoch(False))

        some_dt = datetime.now()
        self.assertEqual(HistoryMiddleware.parse_epoch(some_dt), some_dt)

    def test_parse_human_epoch(self):
        self.assertIsInstance(self.middleware.parse_epoch('yesterday'), datetime)
예제 #5
0
 def test_unconfigured_init(self):
     with self.assertRaises(NotConfigured):
         self.middleware = HistoryMiddleware(get_crawler())
예제 #6
0
 def setUp(self):
     settings_dict = {k: 'mock setting' for k in MANDATORY_SETTINGS}
     crawler = get_crawler(settings_dict=settings_dict)
     self.middleware = HistoryMiddleware(crawler)
 def test_unconfigured_init(self):
     with self.assertRaises(NotConfigured):
         self.middleware = HistoryMiddleware(settings={})
 def setUp(self):
     self.middleware = HistoryMiddleware()
 def test_unconfigured_init(self):
     with self.assertRaises(NotConfigured):
         self.middleware = HistoryMiddleware(settings={})
 def setUp(self):
     self.middleware = HistoryMiddleware()