예제 #1
0
class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

    def test_network_required(self):
        """Test the property network_required."""
        assert self.module.network_required is False

    def test_required_space(self):
        """Test the required_space property."""
        assert self.module.required_space == 0

    @patch("os.path.ismount")
    def test_get_state(self, ismount_mock):
        """Test SE/HMC 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_set_up_with_tasks(self):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        assert len(tasks) == 1

        task = tasks[0]
        assert isinstance(task, SetUpHMCSourceTask)
        assert task._target_mount == self.module.mount_point

    def test_tear_down_with_tasks(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        assert len(tasks) == 1

        task = tasks[0]
        assert isinstance(task, TearDownMountTask)

    def test_repr(self):
        assert repr(self.module) == "Source(type='HMC')"
예제 #2
0
class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

    def network_required_test(self):
        """Test the property network_required."""
        self.assertEqual(self.module.network_required, False)

    def required_space_test(self):
        """Test the required_space property."""
        self.assertEqual(self.module.required_space, 0)

    @patch("os.path.ismount")
    def get_state_test(self, ismount_mock):
        """Test SE/HMC 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 set_up_with_tasks_test(self):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, SetUpHMCSourceTask)
        self.assertEqual(task._target_mount, self.module.mount_point)

    def tear_down_with_tasks_test(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, TearDownMountTask)

    def repr_test(self):
        self.assertEqual(repr(self.module), "Source(type='HMC')")