def test_options_parsing(self): spider = DefaultSpider() spider.settings = Settings() spider.settings.setdict({ 'BIGML_USERNAME': '******', 'BIGML_API_KEY': 'sett_apikey', 'BIGML_SOURCE_NAME': 'sett_source' }) with mock.patch.object(BigMLFeedStorage, 'get_bigml_api') as m: storage = BigMLFeedStorage("bigml://") with storage.open(spider): m.assert_called_once_with(username='******', api_key='sett_apikey', dev_mode=False) self.assertEqual(storage.source_name, 'sett_source') m.reset_mock() spider.settings.set('BIGML_DEVMODE', True) storage = BigMLFeedStorage("bigml://*****:*****@source") with storage.open(spider): m.assert_called_once_with(username='******', api_key='apikey', dev_mode=True) self.assertEqual(storage.source_name, 'source')
def test_crawler_rejects_spider_objects(self): with raises(ValueError): Crawler(DefaultSpider())