示例#1
0
 def test_state_attribute(self):
     # state attribute must be present if jobdir is not set, to provide a
     # consistent interface
     spider = Spider(name='default')
     ss = SpiderState()
     ss.spider_opened(spider)
     self.assertEqual(spider.state, {})
     ss.spider_closed(spider)
示例#2
0
    def test_store_load(self):
        jobdir = self.mktemp()
        os.mkdir(jobdir)
        spider = Spider(name='default')
        dt = datetime.now()

        ss = SpiderState(jobdir)
        ss.spider_opened(spider)
        spider.state['one'] = 1
        spider.state['dt'] = dt
        ss.spider_closed(spider)

        spider2 = Spider(name='default')
        ss2 = SpiderState(jobdir)
        ss2.spider_opened(spider2)
        self.assertEqual(spider.state, {'one': 1, 'dt': dt})
        ss2.spider_closed(spider2)
示例#3
0
    def test_store_load(self):
        jobdir = self.mktemp()
        os.mkdir(jobdir)
        spider = Spider(name="default")
        dt = datetime.now()

        ss = SpiderState(jobdir)
        ss.spider_opened(spider)
        spider.state["one"] = 1
        spider.state["dt"] = dt
        ss.spider_closed(spider)

        spider2 = Spider(name="default")
        ss2 = SpiderState(jobdir)
        ss2.spider_opened(spider2)
        self.assertEqual(spider.state, {"one": 1, "dt": dt})
        ss2.spider_closed(spider2)
示例#4
0
 def test_state_attribute(self):
     # state attribute must be present if jobdir is not set, to provide a
     # consistent interface
     spider = Spider(name='default')
     ss = SpiderState()
     ss.spider_opened(spider)
     self.assertEqual(spider.state, {})
     ss.spider_closed(spider)
示例#5
0
    def test_store_load(self):
        jobdir = self.mktemp()
        os.mkdir(jobdir)
        spider = Spider(name='default')
        dt = datetime.now()

        ss = SpiderState(jobdir)
        ss.spider_opened(spider)
        spider.state['one'] = 1
        spider.state['dt'] = dt
        ss.spider_closed(spider)

        spider2 = Spider(name='default')
        ss2 = SpiderState(jobdir)
        ss2.spider_opened(spider2)
        self.assertEqual(spider.state, {'one': 1, 'dt': dt})
        ss2.spider_closed(spider2)