def testParsingValid(self): index = package_index.PackageIndex('dummy_file', test_index) arm_config = Configuration('arm', 'newlib', False) i686_config = Configuration('i686', 'newlib', False) self.assertEqual(len(index.packages), 2) self.assertTrue(index.Contains('agg-demo', arm_config)) self.assertTrue(index.Contains('agg-demo', i686_config))
def testContains(self): # Create an empty package index and add a single entry to it index = package_index.PackageIndex('dummy_file', '') config_debug = Configuration('arm', 'newlib', True) config_release = Configuration('arm', 'newlib', False) self.assertFalse(index.Contains('foo', config_release)) index.packages[('foo', config_release)] = { 'NAME': 'dummy', 'BUILD_SDK_VERSION': 123 } with patch('naclports.util.GetSDKVersion') as mock_version: # Setting the mock SDK version to 123 should mean that the # index contains the 'foo' package and it is installable' mock_version.return_value = 123 self.assertTrue(index.Contains('foo', config_release)) self.assertTrue(index.Installable('foo', config_release)) # Setting the mock SDK version to some other version should # mean the index contains that package but it is not installable. mock_version.return_value = 124 self.assertTrue(index.Contains('foo', config_release)) self.assertFalse(index.Installable('foo', config_release)) self.assertFalse(index.Contains('foo', config_debug)) self.assertFalse(index.Contains('bar', config_release))
def testDownload(self, download_file_mock): index = package_index.PackageIndex('dummy_file', test_index) arm_config = Configuration('arm', 'newlib', False) index.Download('agg-demo', arm_config) self.assertEqual(download_file_mock.call_count, 1)
def testParsingInvalid(self): contents = 'FOO=bar\nBAR=baz\n' expected_error = "Invalid key 'FOO' in info file dummy_file:1" with self.assertRaisesRegexp(error.Error, expected_error): package_index.PackageIndex('dummy_file', contents)