~viswesn/juju-ci-tools/aws_boto3

« back to all changes in this revision

Viewing changes to tests/test_pipdeps.py

  • Committer: Curtis Hovey
  • Date: 2016-06-20 19:42:23 UTC
  • mto: This revision was merged to the branch mainline in revision 1481.
  • Revision ID: curtis@canonical.com-20160620194223-zfdupcy371rmj83d
uninstall obsolete packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
                ["--download", "/tmp/pip"], self.req_path, verbose=True)
82
82
        cc_mock.assert_called_once_with([
83
83
            "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, verbose=False)
 
99
        co_mock.assert_called_once_with(['pip', '-q', 'list'])
 
100
        cc_mock.assert_called_once_with(['pip', '-q', 'uninstall', 'azure'])