-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_deploy.py
More file actions
45 lines (38 loc) · 1.72 KB
/
test_deploy.py
File metadata and controls
45 lines (38 loc) · 1.72 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
"""Tests the deploy script included in the template"""
import os
import subprocess
import tempfile
import pytest
import deploy
def test_deploy(mocker):
"""Tests deploy.deploy"""
version_return = subprocess.CompletedProcess([], returncode=0, stdout=b'version')
mocker.patch.dict(os.environ, {
deploy.CIRCLECI_ENV_VAR: '1',
'CIRCLE_BRANCH': 'master',
'PROD_PYPI_USERNAME': 'user',
'PROD_PYPI_PASSWORD': 'pass'
})
mocker.patch('os.listdir', return_value=[])
mock_shell = mocker.patch('deploy._shell',
autospec=True,
side_effect=[
None, None, None,
version_return,
None, None, None, None, None, None, None
])
deploy.deploy('PROD')
assert mock_shell.call_args_list == [
# NOTE: This git config call would normally have its value rendered by cookiecutter
mocker.call('git config --global user.email "{{cookiecutter.support_email}}"'),
mocker.call('git config --global user.name "Circle CI"'),
mocker.call('git config push.default current'),
mocker.call('make version', stdout=subprocess.PIPE),
mocker.call('git tag -f -a version -m "Version version"'),
mocker.call('sed -i.bak "s/^__version__ = .*/__version__ = \'version\'/" */version.py'),
mocker.call('python setup.py sdist bdist_wheel'),
mocker.call('git add ChangeLog AUTHORS */version.py'),
mocker.call('git commit --no-verify -m "Merge autogenerated files [skip ci]"'),
mocker.call("twine upload 'dist/*'"),
mocker.call('git push --follow-tags'),
]