示例#1
0
    def test_no_test_values(self):
        """Test that the default values are enforced when no chart `test`
        values are provided (i.e. tests are enabled and cleanup is disabled).
        """
        test_handler = test.Test(release_name='release', tiller=mock.Mock())

        assert test_handler.test_enabled is True
        assert test_handler.cleanup is False
示例#2
0
    def test_deprecated_test_key_false(self):
        """Test that tests can be disabled using the deprecated, boolean value
        for a chart's test key.
        """
        test_handler = test.Test(
            chart={'test': False}, release_name='release', tiller=mock.Mock())

        assert not test_handler.test_enabled
示例#3
0
    def test_cg_disabled(self):
        """Test that tests are disabled when a chart group disables all
        tests.
        """
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 cg_test_charts=False)

        assert test_handler.test_enabled is False
示例#4
0
    def test_deprecated_test_key_timeout(self):
        """Test that the default Tiller timeout is used when tests are enabled
        using the deprecated, boolean value for a chart's `test` key.
        """
        mock_tiller = mock.Mock()
        test_handler = test.Test(
            chart={'test': True}, release_name='release', tiller=mock_tiller)

        assert test_handler.timeout == const.DEFAULT_TEST_TIMEOUT
示例#5
0
    def test_deprecated_test_key_true(self):
        """Test that cleanup is enabled by default when tests are enabled using
        the deprecated, boolean value for a chart's `test` key.
        """
        test_handler = test.Test(
            chart={'test': True}, release_name='release', tiller=mock.Mock())

        assert test_handler.test_enabled is True
        assert test_handler.cleanup is True
示例#6
0
    def test_deprecated_test_key_false(self):
        """Test that tests can be disabled using the deprecated, boolean value
        for a chart's test key.
        """
        test_handler = test.Test(chart={'test': False},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock())

        assert not test_handler.test_enabled
示例#7
0
    def test_cg_enabled_test_key_disabled(self):
        """Test that tests are disabled when a chart group enables all
        tests and the deprecated, boolean `test` key is disabled.
        """
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 cg_test_charts=True,
                                 test_values=False)

        assert test_handler.test_enabled is False
示例#8
0
    def test_no_test_values(self):
        """Test that the default values are enforced when no chart `test`
        values are provided (i.e. tests are enabled).
        """
        test_handler = test.Test(chart={},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock())

        assert test_handler.test_enabled is True
示例#9
0
    def test_tests_disabled(self):
        """Test that tests are disabled by a chart's values using the
        `test.enabled` path.
        """
        test_values = {'enabled': False}
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 test_values=test_values)

        assert test_handler.test_enabled is False
示例#10
0
    def test_enable_all_test_key_disabled(self):
        """Test that tests are enabled when the `enable_all` parameter is
        True and the deprecated, boolean `test` key is disabled.
        """
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 enable_all=True,
                                 test_values=False)

        assert test_handler.test_enabled is True
示例#11
0
    def test_enable_all_cg_disabled(self):
        """Test that tests are enabled when the `enable_all` parameter is
        True and the chart group `test_enabled` key is disabled.
        """
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 cg_test_charts=False,
                                 enable_all=True)

        assert test_handler.test_enabled is True
示例#12
0
    def test_cg_disabled_test_key_enabled(self):
        """Test that tests are enabled when a chart group disables all
        tests and the deprecated, boolean `test` key is enabled.
        """
        test_handler = test.Test(chart={'test': True},
                                 release_name='release',
                                 tiller=mock.Mock(),
                                 cg_test_charts=False)

        assert test_handler.test_enabled is True
示例#13
0
    def test_tests_enabled(self):
        """Test that cleanup is disabled (by default) when tests are enabled by
        a chart's values using the `test.enabled` path.
        """
        test_values = {'enabled': True}
        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 test_values=test_values)

        assert test_handler.test_enabled is True
        assert test_handler.cleanup is False
示例#14
0
    def test_deprecated_test_key_timeout(self):
        """Test that the default helm timeout is used when tests are enabled
        using the deprecated, boolean value for a chart's `test` key.
        """
        mock_helm = mock.Mock()
        test_handler = test.Test(chart={'test': True},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock_helm)

        assert test_handler.timeout == const.DEFAULT_TEST_TIMEOUT
示例#15
0
    def test_cg_enabled_test_key_disabled(self):
        """Test that tests are disabled when a chart group enables all
        tests and the deprecated, boolean `test` key is disabled.
        """
        test_handler = test.Test(chart={'test': False},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock(),
                                 cg_test_charts=True)

        assert test_handler.test_enabled is False
示例#16
0
    def test_enable_all_test_key_disabled(self):
        """Test that tests are enabled when the `enable_all` parameter is
        True and the deprecated, boolean `test` key is disabled.
        """
        test_handler = test.Test(chart={'test': True},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock(),
                                 enable_all=True)

        assert test_handler.test_enabled is True
示例#17
0
    def test_cg_disabled(self):
        """Test that tests are disabled when a chart group disables all
        tests.
        """
        test_handler = test.Test(chart={},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock(),
                                 cg_test_charts=False)

        assert test_handler.test_enabled is False
示例#18
0
    def test_enable_all_test_values_disabled(self):
        """Test that tests are enabled when the `enable_all` parameter is
        True and the `test.enabled` key is False.
        """
        test_values = {'enabled': False}

        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 enable_all=True,
                                 test_values=test_values)

        assert test_handler.test_enabled is True
示例#19
0
    def test_timeout_value(self):
        """Test that a chart's test timeout value, `test.timeout` overrides the
        default test timeout.
        """
        chart = {'test': {'enabled': True, 'timeout': 800}}

        test_handler = test.Test(chart=chart,
                                 release_name='release',
                                 tiller=mock.Mock(),
                                 cleanup=True)

        assert test_handler.timeout is chart['test']['timeout']
示例#20
0
        def do_test(_):
            helm_obj = helm.Helm()
            release = 'release'

            helm_obj.test_release = mock.Mock()
            if exception:
                helm_obj.test_release.side_effect = exception

            test_handler = test.Test({}, release, helm_obj)
            success = test_handler.test_release_for_success()

            self.assertEqual(expected_success, success)
示例#21
0
    def test_timeout_value(self):
        """Test that a chart's test timeout value, `test.timeout` overrides the
        default test timeout.
        """
        chart = {'test': {'enabled': True, 'timeout': 800}}

        test_handler = test.Test(chart=chart,
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock())

        assert test_handler.timeout is chart['test']['timeout']
示例#22
0
    def test_default_timeout_value(self):
        """Test that the default timeout value is used if a test timeout value,
        `test.timeout` is not provided.
        """
        test_handler = test.Test(chart={'test': {
            'enabled': True
        }},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock())

        assert test_handler.timeout == helm.DEFAULT_HELM_TIMEOUT
示例#23
0
    def test_tests_enabled_cleanup_disabled(self):
        """Test that the test handler uses the values provided by a chart's
        `test` key.
        """
        test_values = {'enabled': True, 'options': {'cleanup': False}}

        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 test_values=test_values)

        assert test_handler.test_enabled is True
        assert test_handler.cleanup is False
示例#24
0
    def test_default_timeout_value(self):
        """Test that the default timeout value is used if a test timeout value,
        `test.timeout` is not provided.
        """
        test_handler = test.Test(chart={'test': {
            'enabled': True
        }},
                                 release_name='release',
                                 tiller=mock.Mock(),
                                 cleanup=True)

        assert test_handler.timeout == const.DEFAULT_TILLER_TIMEOUT
示例#25
0
    def test_tests_disabled(self):
        """Test that tests are disabled by a chart's values using the
        `test.enabled` path.
        """
        test_handler = test.Test(chart={'test': {
            'enabled': False
        }},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock())

        assert test_handler.test_enabled is False
示例#26
0
    def test_cg_disabled_test_values_enabled(self):
        """Test that tests are enabled when a chart group disables all
        tests and the `test.enabled` key is False.
        """
        test_values = {'enabled': True}

        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 cg_test_charts=False,
                                 test_values=test_values)

        assert test_handler.test_enabled is True
示例#27
0
    def test_enable_all_cg_disabled(self):
        """Test that tests are enabled when the `enable_all` parameter is
        True and the chart group `test_enabled` key is disabled.
        """
        test_handler = test.Test(chart={},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock(),
                                 cg_test_charts=False,
                                 enable_all=True)

        assert test_handler.test_enabled is True
示例#28
0
        def do_test(_):
            tiller_obj = tiller.Tiller('host', '8080', None)
            release = 'release'

            tiller_obj.test_release = mock.Mock()
            tiller_obj.test_release.return_value = AttrDict(
                **{'results': results})

            test_handler = test.Test(release, tiller_obj)
            success = test_handler.test_release_for_success()

            self.assertEqual(expected_success, success)
示例#29
0
    def test_override_cleanup(self):
        """Test that a cleanup value passed to the Test handler (i.e. from the
        API/CLI) takes precedence over a chart's `test.cleanup` value.
        """
        test_values = {'enabled': True, 'options': {'cleanup': False}}

        test_handler = test.Test(release_name='release',
                                 tiller=mock.Mock(),
                                 cleanup=True,
                                 test_values=test_values)

        assert test_handler.test_enabled is True
        assert test_handler.cleanup is True
示例#30
0
    def test_cg_disabled_test_values_enabled(self):
        """Test that tests are enabled when a chart group disables all
        tests and the `test.enabled` key is False.
        """
        test_handler = test.Test(chart={'test': {
            'enabled': True
        }},
                                 release_id=helm.HelmReleaseId(
                                     'release_ns', 'release'),
                                 helm=mock.Mock(),
                                 cg_test_charts=False)

        assert test_handler.test_enabled is True