예제 #1
0
    def test_get_files_with_unicode_characters(self):
        chart_dir = self.useFixture(fixtures.TempDir())
        self.addCleanup(shutil.rmtree, chart_dir.path)
        for filename in ['foo', 'bar', 'Chart.yaml', 'values.yaml']:
            self._write_temporary_file_contents(
                chart_dir.path, filename, "DIRC^@^@^@^B^@^@^@×Z®<86>F.1")

        chartbuilder = ChartBuilder(self._get_test_chart(chart_dir))
        chartbuilder.get_files()
예제 #2
0
    def test_get_files_fails_once_to_read_binary_file_passes(self):
        chart_dir = self.useFixture(fixtures.TempDir())
        self.addCleanup(shutil.rmtree, chart_dir.path)
        files = ['foo', 'bar']
        for filename in files:
            self._write_temporary_file_contents(
                chart_dir.path, filename, "DIRC^@^@^@^B^@^@^@×Z®<86>F.1")

        chartbuilder = ChartBuilder(self._get_test_chart(chart_dir))

        side_effects = [self.exc_to_raise, "", ""]
        with mock.patch("builtins.open", mock.mock_open(read_data="")) \
                as mock_file:
            mock_file.return_value.read.side_effect = side_effects
            chartbuilder.get_files()
예제 #3
0
    def test_get_files(self):
        """Validates that ``get_files()`` ignores 'Chart.yaml', 'values.yaml'
        and 'templates' subfolder and all the files contained therein.
        """

        # Create a temporary directory that represents a chart source directory
        # with various files, including 'Chart.yaml' and 'values.yaml' which
        # should be ignored by `get_files()`.
        chart_dir = self.useFixture(fixtures.TempDir())
        self.addCleanup(shutil.rmtree, chart_dir.path)
        for filename in ['foo', 'bar', 'Chart.yaml', 'values.yaml']:
            self._write_temporary_file_contents(chart_dir.path, filename, "")

        # Create a template directory -- 'templates' -- nested inside the chart
        # directory which should also be ignored.
        templates_subdir = self._make_temporary_subdirectory(
            chart_dir.path, 'templates')
        for filename in ['template%d' % x for x in range(3)]:
            self._write_temporary_file_contents(templates_subdir, filename, "")

        chartbuilder = ChartBuilder(self._get_test_chart(chart_dir))

        expected_files = ('[type_url: "%s"\n, type_url: "%s"\n]' %
                          ('./bar', './foo'))
        # Validate that only 'foo' and 'bar' are returned.
        actual_files = sorted(chartbuilder.get_files(),
                              key=lambda x: x.type_url)
        self.assertEqual(expected_files, repr(actual_files).strip())