Skip to content

Commit

Permalink
Merge pull request #11 from redapple/data-path-in-project
Browse files Browse the repository at this point in the history
Mock tests as if running inside a scrapy project
  • Loading branch information
redapple authored Dec 7, 2016
2 parents c135544 + e0b7118 commit c9b36fc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_deltafetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def test_init_from_crawler(self):
# void settings
crawler.settings = Settings({})
self.assertRaises(NotConfigured, self.mwcls.from_crawler, crawler)
with mock.patch('scrapy.utils.project.project_data_dir') as data_dir:
with mock.patch('scrapy.utils.project.project_data_dir') as data_dir, \
mock.patch('scrapy.utils.project.inside_project') as in_project:
data_dir.return_value = self.temp_dir
in_project.return_value = True

# simple project_data_dir mock with based settings
crawler.settings = Settings({'DELTAFETCH_ENABLED': True})
Expand Down Expand Up @@ -251,8 +253,10 @@ def __init__(self, dir, reset=False, *args, **kwargs):
crawler.settings = Settings({})
self.assertRaises(NotConfigured, self.mwcls.from_crawler, crawler)

with mock.patch('scrapy.utils.project.project_data_dir') as data_dir:
with mock.patch('scrapy.utils.project.project_data_dir') as data_dir, \
mock.patch('scrapy.utils.project.inside_project') as in_project:
data_dir.return_value = self.temp_dir
in_project.return_value = True

# simple project_data_dir mock with based settings
crawler.settings = Settings({'DELTAFETCH_ENABLED': True})
Expand Down

0 comments on commit c9b36fc

Please sign in to comment.