~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_pipdeps.py

  • Committer: John George
  • Date: 2016-02-05 22:13:41 UTC
  • mto: This revision was merged to the branch mainline in revision 1275.
  • Revision ID: john.george@canonical.com-20160205221341-3v2px3j23ik1zw5r
virtual maas templates and setup script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        parser = pipdeps.get_parser("pipdeps.py")
23
23
        args = parser.parse_args(["-v", "install"])
24
24
        self.assertEqual("install", args.command)
25
 
        self.assertEqual(pipdeps.get_requirements(), args.requirements)
26
25
        self.assertEqual(True, args.verbose)
27
26
 
28
27
    def test_update_cloud_city(self):
71
70
 
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"])
77
76
 
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"])
84
 
 
85
 
 
86
 
class TestRunPipUninstall(unittest.TestCase):
87
 
 
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'])
102
 
 
103
 
 
104
 
class TestGetRequirements(unittest.TestCase):
105
 
 
106
 
    def test_get_requirements(self):
107
 
        dists = [
108
 
            ('Ubuntu', '16.04', 'xenial'),
109
 
            ('debian', 'squeeze/sid', ''),
110
 
            ('centos', '7.2.1511', 'Core'),
111
 
            ('', '', ''),  # Windows and MacOS
112
 
            ]
113
 
        with mock.patch('platform.dist', autospec=True,
114
 
                        side_effect=dists):
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())
118
 
 
119
 
            self.assertEqual(pipdeps.MAC_WIN_REQS, pipdeps.get_requirements())