| OLD | NEW |
| 1 # Copyright 2014 The Native Client Authors. All rights reserved. | 1 # Copyright 2014 The Native Client Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from mock import call, patch, Mock | 5 from mock import call, patch, Mock |
| 6 | 6 |
| 7 import common | 7 import common |
| 8 from naclports import package | 8 from naclports import package |
| 9 | 9 |
| 10 test_info = '''\ | 10 test_info = '''\ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 file_mock = common.MockFileObject(test_info) | 22 file_mock = common.MockFileObject(test_info) |
| 23 with patch('__builtin__.open', Mock(return_value=file_mock), create=True): | 23 with patch('__builtin__.open', Mock(return_value=file_mock), create=True): |
| 24 return package.InstalledPackage('dummy_file') | 24 return package.InstalledPackage('dummy_file') |
| 25 | 25 |
| 26 | 26 |
| 27 class TestInstalledPackage(common.NaclportsTest): | 27 class TestInstalledPackage(common.NaclportsTest): |
| 28 | 28 |
| 29 @patch('naclports.package.Log', Mock()) | 29 @patch('naclports.package.Log', Mock()) |
| 30 @patch('naclports.package.RemoveFile') | 30 @patch('naclports.package.RemoveFile') |
| 31 @patch('os.path.lexists', Mock(return_value=True)) | 31 @patch('os.path.lexists', Mock(return_value=True)) |
| 32 @patch('os.path.exists', Mock(return_value=True)) |
| 32 def testUninstall(self, remove_patch): # pylint: disable=no-self-use | 33 def testUninstall(self, remove_patch): # pylint: disable=no-self-use |
| 33 pkg = CreateMockInstalledPackage() | 34 pkg = CreateMockInstalledPackage() |
| 34 pkg.Files = Mock(return_value=['f1', 'f2']) | 35 pkg.Files = Mock(return_value=['f1', 'f2']) |
| 35 pkg.Uninstall() | 36 pkg.Uninstall() |
| 36 | 37 |
| 37 # Assert that exactly 4 files we removed using RemoveFile | 38 # Assert that exactly 4 files we removed using RemoveFile |
| 38 calls = [call('/package/install/path/var/lib/npkg/foo.info'), | 39 calls = [call('/package/install/path/var/lib/npkg/foo.info'), |
| 39 call('/package/install/path/f1'), | 40 call('/package/install/path/f1'), |
| 40 call('/package/install/path/f2'), | 41 call('/package/install/path/f2'), |
| 41 call('/package/install/path/var/lib/npkg/foo.list')] | 42 call('/package/install/path/var/lib/npkg/foo.list')] |
| 42 remove_patch.assert_has_calls(calls) | 43 remove_patch.assert_has_calls(calls) |
| OLD | NEW |