| 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 patch, Mock | 5 from mock import patch, Mock |
| 6 import os | 6 import os |
| 7 import tempfile | 7 import tempfile |
| 8 | 8 |
| 9 import common | 9 import common |
| 10 from naclports import error | 10 from naclports import error |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 self.assertTrue(index.Contains('agg-demo', arm_config)) | 66 self.assertTrue(index.Contains('agg-demo', arm_config)) |
| 67 self.assertTrue(index.Contains('agg-demo', i686_config)) | 67 self.assertTrue(index.Contains('agg-demo', i686_config)) |
| 68 | 68 |
| 69 def testContains(self): | 69 def testContains(self): |
| 70 # Create an empty package index and add a single entry to it | 70 # Create an empty package index and add a single entry to it |
| 71 index = package_index.PackageIndex('dummy_file', '') | 71 index = package_index.PackageIndex('dummy_file', '') |
| 72 config_debug = Configuration('arm', 'newlib', True) | 72 config_debug = Configuration('arm', 'newlib', True) |
| 73 config_release = Configuration('arm', 'newlib', False) | 73 config_release = Configuration('arm', 'newlib', False) |
| 74 self.assertFalse(index.Contains('foo', config_release)) | 74 self.assertFalse(index.Contains('foo', config_release)) |
| 75 index.packages[('foo', config_release)] = { | 75 index.packages[('foo', config_release)] = { |
| 76 'NAME': 'dummy', | 76 'NAME': 'dummy', |
| 77 'BUILD_SDK_VERSION': 123 | 77 'BUILD_SDK_VERSION': 123 |
| 78 } | 78 } |
| 79 with patch('naclports.util.GetSDKVersion') as mock_version: | 79 with patch('naclports.util.GetSDKVersion') as mock_version: |
| 80 # Setting the mock SDK version to 123 should mean that the | 80 # Setting the mock SDK version to 123 should mean that the |
| 81 # index contains the 'foo' package and it is installable' | 81 # index contains the 'foo' package and it is installable' |
| 82 mock_version.return_value = 123 | 82 mock_version.return_value = 123 |
| 83 self.assertTrue(index.Contains('foo', config_release)) | 83 self.assertTrue(index.Contains('foo', config_release)) |
| 84 self.assertTrue(index.Installable('foo', config_release)) | 84 self.assertTrue(index.Installable('foo', config_release)) |
| 85 | 85 |
| 86 # Setting the mock SDK version to some other version should | 86 # Setting the mock SDK version to some other version should |
| 87 # mean the index contains that package but it is not installable. | 87 # mean the index contains that package but it is not installable. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 104 | 104 |
| 105 @patch('naclports.util.HashFile', Mock(return_value='sha1')) | 105 @patch('naclports.util.HashFile', Mock(return_value='sha1')) |
| 106 @patch('os.path.getsize', Mock(return_value=100)) | 106 @patch('os.path.getsize', Mock(return_value=100)) |
| 107 def testWriteIndex(self): | 107 def testWriteIndex(self): |
| 108 temp_file = tempfile.mkstemp('naclports_test')[1] | 108 temp_file = tempfile.mkstemp('naclports_test')[1] |
| 109 self.addCleanup(os.remove, temp_file) | 109 self.addCleanup(os.remove, temp_file) |
| 110 | 110 |
| 111 with patch('naclports.package_index.ExtractPkgInfo', | 111 with patch('naclports.package_index.ExtractPkgInfo', |
| 112 Mock(return_value=test_info)): | 112 Mock(return_value=test_info)): |
| 113 package_index.WriteIndex(temp_file, (('pkg1', 'url1'), ('pkg2', 'url2'))) | 113 package_index.WriteIndex(temp_file, (('pkg1', 'url1'), ('pkg2', 'url2'))) |
| OLD | NEW |