예제 #1
0
    def test_build_with_skip(self, mock_load_config_files, mock_get_builder,
                             mock_os_path_exists):
        mock_load_config_files.return_value = fakes.create_disk_images().get(
            'disk_images')

        mock_builder = mock.Mock()
        mock_get_builder.return_value = mock_builder

        mock_os_path_exists.return_value = True

        build_manager = ImageBuildManager(['config/file'], skip=True)
        build_manager.build()

        self.assertEqual(1, mock_os_path_exists.call_count)
예제 #2
0
    def test_build_with_skip(self, mock_load_config_files, mock_get_builder,
                             mock_os_path_exists):
        mock_load_config_files.return_value = fakes.create_disk_images().get(
            'disk_images')

        mock_builder = mock.Mock()
        mock_get_builder.return_value = mock_builder

        mock_os_path_exists.return_value = True

        build_manager = ImageBuildManager(['config/file'], skip=True)
        build_manager.build()

        self.assertEqual(1, mock_os_path_exists.call_count)
예제 #3
0
    def test_build(self, mock_load_config_files, mock_get_builder):
        mock_load_config_files.return_value = fakes.create_disk_images().get(
            'disk_images')

        mock_builder = mock.Mock()
        mock_get_builder.return_value = mock_builder

        build_manager = ImageBuildManager(['config/file'])
        build_manager.build()

        self.assertEqual(1, mock_load_config_files.call_count)

        mock_builder.build_image.assert_called_with(
            './overcloud', 'qcow2', 'some_awesome_os', 'amd64',
            ['image_element'], [], [],
            {'skip_base': False, 'docker_target': None, 'environment': {}})
예제 #4
0
    def test_load_config_files(self, mock_os_path_isfile, mock_yaml_load):
        mock_yaml_load.return_value = fakes.create_disk_images()

        mock_os_path_isfile.return_value = True

        mock_open_context = mock.mock_open()
        mock_open_context().read.return_value = "YAML"

        with mock.patch('builtins.open', mock_open_context):
            base_manager = BaseImageManager(['yamlfile'])
            disk_images = base_manager.load_config_files('disk_images')

        mock_yaml_load.assert_called_once_with("YAML")
        self.assertEqual([{
            'arch': 'amd64',
            'distro': 'some_awesome_os',
            'imagename': 'overcloud',
            'type': 'qcow2',
            'elements': ['image_element']
        }], disk_images)
예제 #5
0
    def test_load_config_files(self, mock_os_path_isfile, mock_yaml_load):
        mock_yaml_load.return_value = fakes.create_disk_images()

        mock_os_path_isfile.return_value = True

        mock_open_context = mock.mock_open()
        mock_open_context().read.return_value = "YAML"

        with mock.patch('six.moves.builtins.open', mock_open_context):
            base_manager = BaseImageManager(['yamlfile'])
            disk_images = base_manager.load_config_files('disk_images')

        mock_yaml_load.assert_called_once_with("YAML")
        self.assertEqual([{
            'arch': 'amd64',
            'distro': 'some_awesome_os',
            'imagename': 'overcloud',
            'type': 'qcow2',
            'elements': ['image_element']
        }], disk_images)