コード例 #1
0
    def test_finddisk(self):
        disk_dvr = mock.Mock()
        disk_dvr.get_disk_ref.return_value = 'disk_ref'
        instance = mock.Mock()
        context = 'context'
        disk_type = 'disk_type'

        task = tf_stg.FindDisk(disk_dvr, context, instance, disk_type)
        ret_disk = task.execute()
        disk_dvr.get_disk_ref.assert_called_once_with(instance, disk_type)
        self.assertEqual('disk_ref', ret_disk)

        # Bad path for no disk found
        disk_dvr.reset_mock()
        disk_dvr.get_disk_ref.return_value = None
        ret_disk = task.execute()
        disk_dvr.get_disk_ref.assert_called_once_with(instance, disk_type)
        self.assertIsNone(ret_disk)

        # Validate args on taskflow.task.Task instantiation
        with mock.patch('taskflow.task.Task.__init__') as tf:
            tf_stg.FindDisk(disk_dvr, context, instance, disk_type)
        tf.assert_called_once_with(name='find_disk', provides='disk_dev_info')
コード例 #2
0
    def test_finddisk(self):
        disk_dvr = mock.Mock()
        disk_dvr.get_disk_ref.return_value = 'disk_ref'
        instance = mock.Mock()
        context = 'context'
        disk_type = 'disk_type'

        task = tf_stg.FindDisk(disk_dvr, context, instance, disk_type)
        ret_disk = task.execute()
        disk_dvr.get_disk_ref.assert_called_once_with(instance, disk_type)
        self.assertEqual('disk_ref', ret_disk)

        # Bad path for no disk found
        disk_dvr.reset_mock()
        disk_dvr.get_disk_ref.return_value = None
        ret_disk = task.execute()
        disk_dvr.get_disk_ref.assert_called_once_with(instance, disk_type)
        self.assertIsNone(ret_disk)