1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-28 05:04:20 +00:00
scrapy/scrapyd/tests/test_environ.py
Pablo Hoffman fa644f7a5e Some simplifications to Scrapyd architecture and internals:
- launcher no longer knows about egg storage
- removed get_spider_list_from_eggifile() file and replaced by simpler
  get_spider_list() which doesn't receive en egg file as argument
- changed "egg runner" name to just "runner" to reflect the fact that it
  doesn't necesarilly run eggs (though it does in the default case)

--HG--
rename : scrapyd/eggrunner.py => scrapyd/runner.py
2010-12-27 16:22:32 -02:00

35 lines
1.2 KiB
Python

import os
from twisted.trial import unittest
from zope.interface.verify import verifyObject
from scrapyd.interfaces import IEnvironment
from scrapyd.config import Config
from scrapyd.environ import Environment
class EnvironmentTest(unittest.TestCase):
def setUp(self):
d = self.mktemp()
os.mkdir(d)
config = Config(values={'eggs_dir': d, 'logs_dir': d})
config.cp.add_section('settings')
config.cp.set('settings', 'newbot', 'newbot.settings')
self.environ = Environment(config, initenv={})
def test_interface(self):
verifyObject(IEnvironment, self.environ)
def test_get_environment_with_eggfile(self):
msg = {'_project': 'mybot', '_spider': 'myspider', '_job': 'ID'}
slot = 3
env = self.environ.get_environment(msg, slot)
self.assertEqual(env['SCRAPY_PROJECT'], 'mybot')
self.assertEqual(env['SCRAPY_SLOT'], '3')
self.assertEqual(env['SCRAPY_SPIDER'], 'myspider')
self.assertEqual(env['SCRAPY_JOB'], 'ID')
self.assert_(env['SCRAPY_SQLITE_DB'].endswith('mybot.db'))
self.assert_(env['SCRAPY_LOG_FILE'].endswith('/mybot/myspider/ID.log'))
self.failIf('SCRAPY_SETTINGS_MODULE' in env)