class CdromSourceTestCase(unittest.TestCase): def setUp(self): self.module = CdromSourceModule() self.interface = CdromSourceInterface(self.module) def type_test(self): """Test CD-ROM source module has a correct type.""" self.assertEqual(SourceType.CDROM, self.module.type) @patch("os.path.ismount") def get_state_test(self, ismount_mock): """Test CD-ROM source state.""" ismount_mock.return_value = False self.assertEqual(SourceState.UNREADY, self.module.get_state()) ismount_mock.reset_mock() ismount_mock.return_value = True self.assertEqual(SourceState.READY, self.module.get_state()) ismount_mock.assert_called_once_with(self.module.mount_point) def description_test(self): """Hard drive source description.""" self.assertEqual("Local media", self.interface.Description) def network_required_test(self): """Test the property network_required.""" self.assertEqual(self.module.network_required, False) def repr_test(self): self.assertEqual(repr(self.module), "Source(type='CDROM')") def set_up_with_tasks_test(self): """Test CD-ROM Source set up call.""" task_classes = [SetUpCdromSourceTask] # task will not be public so it won't be published tasks = self.module.set_up_with_tasks() # Check the number of the tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i]) def tear_down_with_tasks_test(self): """Test CD-ROM Source ready state for tear down.""" task_classes = [TearDownMountTask] # task will not be public so it won't be published tasks = self.module.tear_down_with_tasks() # check the number of tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i])
class CdromSourceTestCase(unittest.TestCase): def setUp(self): self.module = CdromSourceModule() def type_test(self): """Test CD-ROM source module has a correct type.""" self.assertEqual(SourceType.CDROM, self.module.type) def set_up_with_tasks_test(self): """Test CD-ROM Source set up call.""" task_classes = [SetUpCdromSourceTask] # task will not be public so it won't be published tasks = self.module.set_up_with_tasks() # Check the number of the tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i]) def tear_down_with_tasks_test(self): """Test CD-ROM Source ready state for tear down.""" task_classes = [TearDownMountTask] # task will not be public so it won't be published tasks = self.module.tear_down_with_tasks() # check the number of tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i])
class CdromSourceTestCase(unittest.TestCase): def setUp(self): self.cdrom_source_module = CdromSourceModule() def type_test(self): """Test CD-ROM source module has a correct type.""" self.assertEqual(SourceType.CDROM, self.cdrom_source_module.type) def set_up_with_tasks_test(self): """Test CD-ROM Source set up call.""" task_classes = [SetUpCdromSourceTask] # task will not be public so it won't be published tasks = self.cdrom_source_module.set_up_with_tasks() # Check the number of the tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i]) def tear_down_with_tasks_test(self): """Test CD-ROM Source ready state for tear down.""" task_classes = [TearDownCdromSourceTask] # task will not be public so it won't be published tasks = self.cdrom_source_module.tear_down_with_tasks() # check the number of tasks task_number = len(task_classes) self.assertEqual(task_number, len(tasks)) for i in range(task_number): self.assertIsInstance(tasks[i], task_classes[i]) @patch("os.path.ismount") def ready_state_test(self, ismount): """Test CD-ROM Source ready state for set up.""" ismount.return_value = False self.assertFalse(self.cdrom_source_module.is_ready()) ismount.reset_mock() ismount.return_value = True self.assertTrue(self.cdrom_source_module.is_ready()) ismount.assert_called_once_with(INSTALL_TREE)
class CdromSourceInterfaceTestCase(unittest.TestCase): def setUp(self): self.module = CdromSourceModule() self.interface = CdromSourceInterface(self.module) self.callback = PropertiesChangedCallback() self.interface.PropertiesChanged.connect(self.callback) def test_type(self): """Test CD-ROM source has a correct type specified.""" assert SOURCE_TYPE_CDROM == self.interface.Type def test_device(self): """Test CD-ROM source Device API.""" assert self.interface.DeviceName == "" task = self.module.set_up_with_tasks()[0] task.get_result = Mock(return_value="top_secret") task.succeeded_signal.emit() assert self.interface.DeviceName == "top_secret"
class CdromSourceTestCase(unittest.TestCase): def setUp(self): self.module = CdromSourceModule() self.interface = CdromSourceInterface(self.module) def test_type(self): """Test CD-ROM source module has a correct type.""" assert SourceType.CDROM == self.module.type @patch("os.path.ismount") def test_get_state(self, ismount_mock): """Test CD-ROM source state.""" ismount_mock.return_value = False assert SourceState.UNREADY == self.module.get_state() ismount_mock.reset_mock() ismount_mock.return_value = True assert SourceState.READY == self.module.get_state() ismount_mock.assert_called_once_with(self.module.mount_point) def test_description(self): """Hard drive source description.""" assert "Local media" == self.interface.Description def test_network_required(self): """Test the property network_required.""" assert self.module.network_required == False def test_required_space(self): """Test the required_space property.""" assert self.module.required_space == 0 def test_repr(self): assert repr(self.module) == "Source(type='CDROM')" def test_set_up_with_tasks(self): """Test CD-ROM Source set up call.""" task_classes = [SetUpCdromSourceTask] # task will not be public so it won't be published tasks = self.module.set_up_with_tasks() # Check the number of the tasks task_number = len(task_classes) assert task_number == len(tasks) for i in range(task_number): assert isinstance(tasks[i], task_classes[i]) def test_tear_down_with_tasks(self): """Test CD-ROM Source ready state for tear down.""" task_classes = [TearDownMountTask] # task will not be public so it won't be published tasks = self.module.tear_down_with_tasks() # check the number of tasks task_number = len(task_classes) assert task_number == len(tasks) for i in range(task_number): assert isinstance(tasks[i], task_classes[i])