class LiveImageModuleTestCase(unittest.TestCase): def setUp(self): self.module = LiveImageModule() def test_calculate_required_space(self): """Test the calculate_required_space method.""" self.assertEqual(self.module.calculate_required_space(), 0) source = SourceFactory.create_source(SourceType.LIVE_IMAGE) self.module.add_source(source) self.assertEqual(self.module.calculate_required_space(), 1024 * 1024 * 1024) def test_install_with_task_from_tar(self): """Test Live Image install with tasks from tarfile.""" # task_path = self.live_image_interface.PreInstallWithTasks() # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask]) # task_path = self.live_image_interface.InstallWithTasks() # check_task_creation_list(self, task_path, publisher, [InstallFromTarTask]) self.assertEqual(self.module.install_with_tasks(), []) @patch_dbus_publish_object def test_install_with_task_from_image(self, publisher): """Test Live Image install with tasks from image.""" # task_path = self.live_image_interface.PreInstallWithTasks() # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask]) # task_path = self.live_image_interface.InstallWithTasks() # check_task_creation_list(self, task_path, publisher, [InstallFromImageTask]) self.assertEqual(self.module.install_with_tasks(), []) @patch_dbus_publish_object def test_post_install_with_tasks(self, publisher): """Test Live Image post installation configuration task.""" # task_classes = [ # TeardownInstallationSourceImageTask # ] # # task_paths = self.live_image_interface.PostInstallWithTasks() # # # Check the number of installation tasks. # task_number = len(task_classes) # self.assertEqual(task_number, len(task_paths)) # self.assertEqual(task_number, publisher.call_count) # # # Check the tasks. # for i in range(task_number): # object_path, obj = publisher.call_args_list[i][0] # self.assertEqual(object_path, task_paths[i]) # self.assertIsInstance(obj, TaskInterface) # self.assertIsInstance(obj.implementation, task_classes[i]) self.assertEqual(self.module.post_install_with_tasks(), [])
class LiveImageModuleTestCase(unittest.TestCase): def setUp(self): self.module = LiveImageModule() def test_multiple_sources(self): """The live image payload cannot have multiple sources.""" sources = [ SourceFactory.create_source(SourceType.LIVE_IMAGE), SourceFactory.create_source(SourceType.LIVE_IMAGE) ] with pytest.raises(IncompatibleSourceError) as cm: self.module.set_sources(sources) assert str( cm.value) == "You can set only one source for this payload type." def test_calculate_required_space(self): """Test the calculate_required_space method.""" assert self.module.calculate_required_space() == 0 source = SourceFactory.create_source(SourceType.LIVE_IMAGE) self.module.add_source(source) assert self.module.calculate_required_space() == 1024 * 1024 * 1024 def test_install_with_task_from_tar(self): """Test installation tasks with a tarfile.""" assert self.module.install_with_tasks() == [] source = SourceFactory.create_source(SourceType.LIVE_TAR) self.module.add_source(source) tasks = self.module.install_with_tasks() assert len(tasks) == 1 assert isinstance(tasks[0], InstallLiveTarTask) def test_install_with_task_from_image(self): """Test installation tasks with an image.""" assert self.module.install_with_tasks() == [] source = SourceFactory.create_source(SourceType.LIVE_IMAGE) self.module.add_source(source) tasks = self.module.install_with_tasks() assert len(tasks) == 1 assert isinstance(tasks[0], InstallLiveImageTask) def test_post_install_with_tasks(self): """Test post-installation tasks.""" assert self.module.post_install_with_tasks() == []
class LiveImageInterfaceTestCase(unittest.TestCase): def setUp(self): self.live_image_module = LiveImageModule() self.live_image_interface = LiveImageInterface(self.live_image_module) self.shared_tests = PayloadSharedTest( self, payload=self.live_image_module, payload_intf=self.live_image_interface) def type_test(self): self.shared_tests.check_type(PayloadType.LIVE_IMAGE) def calculate_required_space_test(self): """Test CalculateRequiredTest.""" self.assertEqual(self.live_image_interface.CalculateRequiredSpace(), 0) source = SourceFactory.create_source(SourceType.LIVE_IMAGE) self.live_image_module.add_source(source) self.assertEqual(self.live_image_interface.CalculateRequiredSpace(), 1024 * 1024 * 1024) # TODO: Add set_source and supported_sources like in Live OS payload when source is available @patch_dbus_publish_object def prepare_system_for_installation_task_test(self, publisher): """Test Live Image is able to create a prepare installation task.""" # task_path = self.live_image_interface.PreInstallWithTasks() # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask]) self.assertEqual(self.live_image_interface.PreInstallWithTasks(), []) @patch_dbus_publish_object def install_with_task_from_tar_test(self, publisher): """Test Live Image install with tasks from tarfile.""" # task_path = self.live_image_interface.InstallWithTasks() # check_task_creation_list(self, task_path, publisher, [InstallFromTarTask]) self.assertEqual(self.live_image_interface.InstallWithTasks(), []) @patch_dbus_publish_object def install_with_task_from_image_test(self, publisher): """Test Live Image install with tasks from image.""" # task_path = self.live_image_interface.InstallWithTasks() # check_task_creation_list(self, task_path, publisher, [InstallFromImageTask]) self.assertEqual(self.live_image_interface.InstallWithTasks(), []) @patch_dbus_publish_object def post_install_with_tasks_test(self, publisher): """Test Live Image post installation configuration task.""" # task_classes = [ # UpdateBLSConfigurationTask, # CopyDriverDisksFilesTask, # TeardownInstallationSourceImageTask # ] # # task_paths = self.live_image_interface.PostInstallWithTasks() # # # Check the number of installation tasks. # task_number = len(task_classes) # self.assertEqual(task_number, len(task_paths)) # self.assertEqual(task_number, publisher.call_count) # # # Check the tasks. # for i in range(task_number): # object_path, obj = publisher.call_args_list[i][0] # self.assertEqual(object_path, task_paths[i]) # self.assertIsInstance(obj, TaskInterface) # self.assertIsInstance(obj.implementation, task_classes[i]) self.assertEqual(self.live_image_interface.PostInstallWithTasks(), [])