def test_can_set_package_version(self): package = load_package(self.pkg_fn) self.assertIsNone(package.version) self.runner.invoke( set_version_command, args=[self.version]) package = load_package(self.pkg_fn) self.assertEqual(package.version, self.version)
def test_can_remove_supported_hardware_identifier(self): hardware = 'PowerX' self.pkg.supported_hardware.add(hardware) dump_package(self.pkg.to_template(), self.pkg_fn) pkg = load_package(self.pkg_fn) self.assertEqual(len(pkg.supported_hardware), 1) result = self.runner.invoke(remove_supported_hardware, args=[hardware]) self.assertEqual(result.exit_code, 0) pkg = load_package(self.pkg_fn) self.assertEqual(len(pkg.supported_hardware), 0)
def test_can_add_supported_hardware_identifier(self): hardware = 'PowerX' result = self.runner.invoke(add_supported_hardware, args=[hardware]) self.assertEqual(result.exit_code, 0) pkg = load_package(self.pkg_fn) self.assertEqual(len(pkg.supported_hardware), 1) self.assertIn(hardware, pkg.supported_hardware)
def test_can_edit_object_filename_with_edit_object_command(self): args = [ '--index', '0', '--option', 'filename', '--value', self.pkg_fn] self.runner.invoke(edit_object_command, args=args) pkg = load_package(self.pkg_fn) obj = pkg.objects.get(obj_index=0, set_index=0) self.assertEqual(obj.filename, self.pkg_fn)
def test_can_add_object(self): cmd = [self.obj_fn, '-m', 'raw', '-t', '/dev/sda', '-tt', 'device'] result = self.runner.invoke(add_object_command, cmd) self.assertEqual(result.exit_code, 0) package = load_package(self.pkg_fn) obj = package.objects.get(obj_index=0, set_index=0) self.assertEqual(obj.filename, self.obj_fn) self.assertEqual(obj.mode, 'raw') self.assertEqual(obj['target'], '/dev/sda')
def test_can_edit_object_with_edit_object_command(self): args = [ '--index', '0', '--installation-set', '0', '--option', 'target', '--value', '/dev/sdb'] self.runner.invoke(edit_object_command, args=args) pkg = load_package(self.pkg_fn) obj = pkg.objects.get(obj_index=0, set_index=0) self.assertEqual(obj['target'], '/dev/sdb')
def test_can_dump_and_load_package_from_file(self): pkg_fn = '/tmp/uhu-dump.json' self.addCleanup(self.remove_file, pkg_fn) self.assertFalse(os.path.exists(pkg_fn)) pkg, hw, objs = self.create_package() # dump dump_package(pkg.to_template(), pkg_fn) self.assertTrue(os.path.exists(pkg_fn)) # load new_pkg = load_package(pkg_fn) template = new_pkg.to_template() self.assertEqual(template['version'], self.version) self.assertEqual(template['product'], self.product) self.assertEqual(template[hw.metadata], hw.to_template()[hw.metadata]) self.assertEqual( template[objs.metadata], objs.to_template()[objs.metadata])
def test_can_remove_object_with_remove_command(self): self.runner.invoke( remove_object_command, args=['0']) pkg = load_package(self.pkg_fn) self.assertEqual(len(pkg.objects.all()), 0)