def test_create_with_mkisofs(self, mock_call): """Creation of an ISO with mkisofs (default).""" helpers['mkisofs']._installed = True ISO.create_file(path=self.foo_iso, files=[self.input_ovf]) mock_call.assert_called_with( ['-output', self.foo_iso, '-full-iso9660-filenames', '-iso-level', '2', '-allow-lowercase', '-r', self.input_ovf])
def test_create_with_mkisofs(self, mock_call): """Creation of an ISO with mkisofs (default).""" helpers['mkisofs']._installed = True ISO.create_file(path=self.foo_iso, files=[self.input_ovf]) mock_call.assert_called_with( ['-output', self.foo_iso, '-full-iso9660-filenames', '-iso-level', '2', '-allow-lowercase', '-r', self.input_ovf])
def test_create_with_genisoimage(self, mock_call): """Creation of an ISO with genisoimage if mkisofs is unavailable.""" helpers['mkisofs']._installed = False helpers['genisoimage']._installed = True ISO.create_file(path=self.foo_iso, files=[self.input_ovf]) mock_call.assert_called_with( ['-output', self.foo_iso, '-full-iso9660-filenames', '-iso-level', '2', '-allow-lowercase', '-r', self.input_ovf])
def test_create_with_genisoimage(self, mock_call): """Creation of an ISO with genisoimage if mkisofs is unavailable.""" helpers['mkisofs']._installed = False helpers['genisoimage']._installed = True ISO.create_file(path=self.foo_iso, files=[self.input_ovf]) mock_call.assert_called_with( ['-output', self.foo_iso, '-full-iso9660-filenames', '-iso-level', '2', '-allow-lowercase', '-r', self.input_ovf])
def test_file_is_this_type_noisoinfo(self): """The file_is_this_type API should work if isoinfo isn't available.""" _isoinfo = helpers['isoinfo'] helpers['isoinfo'] = False try: self.assertTrue(ISO.file_is_this_type(self.input_iso)) self.assertFalse(ISO.file_is_this_type(self.blank_vmdk)) finally: helpers['isoinfo'] = _isoinfo
def test_file_is_this_type_noisoinfo(self): """The file_is_this_type API should work if isoinfo isn't available.""" _isoinfo = helpers['isoinfo'] helpers['isoinfo'] = False try: self.assertTrue(ISO.file_is_this_type(self.input_iso)) self.assertFalse(ISO.file_is_this_type(self.blank_vmdk)) finally: helpers['isoinfo'] = _isoinfo
def test_file_is_this_type_isoinfo(self): """The file_is_this_type API should use isoinfo if available.""" if helpers['isoinfo']: self.assertTrue(ISO.file_is_this_type(self.input_iso)) self.assertFalse(ISO.file_is_this_type(self.blank_vmdk)) else: # Fake it til you make it helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call"): self.assertTrue(ISO.file_is_this_type(self.input_iso)) with mock.patch.object(helpers['isoinfo'], "call", side_effect=HelperError): self.assertFalse(ISO.file_is_this_type(self.blank_vmdk))
def test_file_is_this_type_isoinfo(self): """The file_is_this_type API should use isoinfo if available.""" if helpers['isoinfo']: self.assertTrue(ISO.file_is_this_type(self.input_iso)) self.assertFalse(ISO.file_is_this_type(self.blank_vmdk)) else: # Fake it til you make it helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call"): self.assertTrue(ISO.file_is_this_type(self.input_iso)) with mock.patch.object(helpers['isoinfo'], "call", side_effect=HelperError): self.assertFalse(ISO.file_is_this_type(self.blank_vmdk))
def test_representation(self): """Representing an existing ISO.""" iso = ISO(self.input_iso) self.assertEqual(iso.path, self.input_iso) self.assertEqual(iso.disk_format, 'iso') self.assertEqual(iso.capacity, str(self.FILE_SIZE['input.iso'])) if helpers['isoinfo']: self.assertEqual(iso.disk_subformat, "") self.assertEqual(iso.files, ['iosxr_config.txt', 'iosxr_config_admin.txt'])
def test_create_with_files_non_rockridge(self): """Creation of a non-rock-ridge ISO with specific file contents.""" disk_path = os.path.join(self.temp_dir, "out.iso") ISO.create_file(disk_path, files=[self.input_ovf], disk_subformat="") iso = ISO(disk_path) if helpers['isoinfo']: self.assertEqual(iso.disk_subformat, "") self.assertEqual(iso.files, [os.path.basename(self.input_ovf)]) else: helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call", return_value="No SUSP/Rock Ridge present"): self.assertEqual(iso.disk_subformat, "") with mock.patch.object(helpers['isoinfo'], "call", return_value=""" Setting input-charset to 'UTF-8' from locale. /{0};1 """.format(os.path.basename(self.input_ovf).upper())): self.assertEqual(iso.files, [os.path.basename(self.input_ovf)])
def test_create_with_files_non_rockridge(self): """Creation of a non-rock-ridge ISO with specific file contents.""" disk_path = os.path.join(self.temp_dir, "out.iso") ISO.create_file(disk_path, files=[self.input_ovf], disk_subformat="") iso = ISO(disk_path) if helpers['isoinfo']: self.assertEqual(iso.disk_subformat, "") self.assertEqual(iso.files, [os.path.basename(self.input_ovf)]) else: helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call", return_value="No SUSP/Rock Ridge present"): self.assertEqual(iso.disk_subformat, "") with mock.patch.object(helpers['isoinfo'], "call", return_value=""" Setting input-charset to 'UTF-8' from locale. /{0};1 """.format(os.path.basename(self.input_ovf).upper())): self.assertEqual(iso.files, [os.path.basename(self.input_ovf)])
def test_create_with_files(self): """Creation of a ISO with specific file contents.""" disk_path = os.path.join(self.temp_dir, "out.iso") ISO.create_file(disk_path, files=[self.input_ovf]) iso = ISO(disk_path) if helpers['isoinfo']: # Our default create format is rockridge self.assertEqual(iso.disk_subformat, "rockridge") self.assertEqual(iso.files, [os.path.basename(self.input_ovf)]) else: helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call", return_value="Rock Ridge extensions found"): self.assertEqual(iso.disk_subformat, "rockridge") with mock.patch.object(helpers['isoinfo'], "call", return_value=""" Setting input-charset to 'UTF-8' from locale. /{0} """.format(os.path.basename(self.input_ovf))): self.assertEqual(iso.files, [os.path.basename(self.input_ovf)])
def test_create_with_files(self): """Creation of a ISO with specific file contents.""" disk_path = os.path.join(self.temp_dir, "out.iso") ISO.create_file(disk_path, files=[self.input_ovf]) iso = ISO(disk_path) if helpers['isoinfo']: # Our default create format is rockridge self.assertEqual(iso.disk_subformat, "rockridge") self.assertEqual(iso.files, [os.path.basename(self.input_ovf)]) else: helpers['isoinfo']._installed = True with mock.patch.object(helpers['isoinfo'], "call", return_value="Rock Ridge extensions found"): self.assertEqual(iso.disk_subformat, "rockridge") with mock.patch.object(helpers['isoinfo'], "call", return_value=""" Setting input-charset to 'UTF-8' from locale. /{0} """.format(os.path.basename(self.input_ovf))): self.assertEqual(iso.files, [os.path.basename(self.input_ovf)])