72
71
def test_added_args(self):
73
72
with mock.patch("subprocess.check_call", autospec=True) as cc_mock:
74
pipdeps.run_pip_install(["--user"], self.req_path)
73
pipdeps.run_pip_install(["--user"])
75
74
cc_mock.assert_called_once_with([
76
75
"pip", "-q", "install", "-r", self.req_path, "--user"])
78
77
def test_verbose(self):
79
78
with mock.patch("subprocess.check_call", autospec=True) as cc_mock:
80
pipdeps.run_pip_install(
81
["--download", "/tmp/pip"], self.req_path, verbose=True)
79
pipdeps.run_pip_install(["--download", "/tmp/pip"], verbose=True)
82
80
cc_mock.assert_called_once_with([
83
81
"pip", "install", "-r", self.req_path, "--download", "/tmp/pip"])
86
class TestRunPipUninstall(unittest.TestCase):
88
def test_run_pip_uninstall(self):
89
with utility.temp_dir() as base:
90
obsolete = os.path.join(base, 'obsolete.txt')
91
with open(obsolete, 'w') as o_file:
92
o_file.write('foo (9.7.6)\nazure (0.8.0)')
93
list_output = 'azure (0.8.0)\nbar (1.2.3)'
94
with mock.patch("subprocess.check_output", autospec=True,
95
return_value=list_output) as co_mock:
96
with mock.patch("subprocess.check_call",
97
autospec=True) as cc_mock:
98
pipdeps.run_pip_uninstall(obsolete)
99
co_mock.assert_called_once_with(['pip', 'list'])
100
cc_mock.assert_called_once_with(
101
['pip', 'uninstall', '-y', 'azure'])
104
class TestGetRequirements(unittest.TestCase):
106
def test_get_requirements(self):
108
('Ubuntu', '16.04', 'xenial'),
109
('debian', 'squeeze/sid', ''),
110
('centos', '7.2.1511', 'Core'),
111
('', '', ''), # Windows and MacOS
113
with mock.patch('platform.dist', autospec=True,
115
self.assertEqual(pipdeps.REQUIREMENTS, pipdeps.get_requirements())
116
self.assertEqual(pipdeps.REQUIREMENTS, pipdeps.get_requirements())
117
self.assertEqual(pipdeps.MAC_WIN_REQS, pipdeps.get_requirements())
119
self.assertEqual(pipdeps.MAC_WIN_REQS, pipdeps.get_requirements())