forked from scrapinghub/shub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_deploy.py
More file actions
50 lines (38 loc) · 1.25 KB
/
Copy pathtest_deploy.py
File metadata and controls
50 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# coding=utf-8
import os
import unittest
from shub import deploy
from click.testing import CliRunner
from mock import patch
class DeployTest(unittest.TestCase):
def setUp(self):
self.runner = CliRunner()
os.environ['SHUB_APIKEY'] = '1234'
def test_fails_when_deploy_is_invoked_outside_of_a_scrapy_project(self):
# given there's no scrapy.cfg file in the current folder
with self.runner.isolated_filesystem():
# when
result = self.runner.invoke(deploy.cli)
# then
self.assertEqual(1, result.exit_code)
@patch('shub.deploy.make_deploy_request')
def test_parses_project_cfg_and_uploads_egg(self, deploy_req_mock):
# given
valid_scrapy_cfg = """
[deploy]
username = API_KEY
project = -1
[settings]
default = project.settings
"""
with self.runner.isolated_filesystem():
with open('scrapy.cfg', 'w') as f:
f.write(valid_scrapy_cfg)
# when
result = self.runner.invoke(deploy.cli)
# then
err = 'Output: %s\nException: %s' % (result.output, result.exception)
self.assertEqual(0, result.exit_code, err)
if __name__ == '__main__':
unittest.main()