Esempio n. 1
0
 def test_build_root_config_overwrite(self):
     cfg = build_root_config('tests.files.settings_overwrite')
     for key, val in DEFAULT_SPIDER_GLOBAL_CONFIG.items():
         if key == 'spider_modules':
             self.assertEqual(cfg['global'][key], ['zzz'])
         else:
             self.assertEqual(cfg['global'][key], val)
Esempio n. 2
0
 def test_build_root_config_overwrite(self):
     cfg = build_root_config('test.files.settings_overwrite')
     for key, val in DEFAULT_SPIDER_GLOBAL_CONFIG.items():
         if key == 'spider_modules':
             self.assertEqual(cfg['global'][key], ['zzz'])
         else:
             self.assertEqual(cfg['global'][key], val)
Esempio n. 3
0
 def test_build_spider_config_overwrite(self):
     class TestSpider(Spider): pass
     root_cfg = build_root_config('test.files.settings_test_spider')
     cfg = build_spider_config(TestSpider, root_cfg)
     for key, val in  DEFAULT_SPIDER_GLOBAL_CONFIG.items():
         if key == 'spider_modules':
             self.assertEqual(cfg[key], ['zzz'])
         elif key == 'thread_number':
             self.assertEqual(cfg[key], 777)
         else:
             self.assertEqual(cfg[key], val)
Esempio n. 4
0
    def test_setup_spider_config(self):
        class TestSpider(Spider):
            @classmethod
            def setup_spider_config(cls, config):
                config['foo'] = 'bar'

        root_cfg = build_root_config('tests.files.settings_minimal')
        cfg = build_spider_config(TestSpider, root_cfg)
        for key, val in DEFAULT_SPIDER_GLOBAL_CONFIG.items():
            if key == 'foo':
                self.assertEqual(cfg[key], 'bar')
            else:
                self.assertEqual(cfg[key], val)
Esempio n. 5
0
    def test_setup_spider_config(self):
        class TestSpider(Spider):
            @classmethod
            def setup_spider_config(cls, config):
                config['foo'] = 'bar'

        root_cfg = build_root_config('test.files.settings_minimal')
        cfg = build_spider_config(TestSpider, root_cfg)
        for key, val in DEFAULT_SPIDER_GLOBAL_CONFIG.items():
            if key == 'foo':
                self.assertEqual(cfg[key], 'bar')
            else:
                self.assertEqual(cfg[key], val)