From e3164012d4bc691da7dea0e161a13066e49eacc6 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 29 Oct 2021 22:24:58 +0000 Subject: [PATCH 1/2] test: add tests for autogen-snippets option --- tests/unit/generator/test_options.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/unit/generator/test_options.py b/tests/unit/generator/test_options.py index d5bd11f64e..44df9a92a6 100644 --- a/tests/unit/generator/test_options.py +++ b/tests/unit/generator/test_options.py @@ -141,9 +141,7 @@ def test_options_service_config(fs): def test_options_bool_flags(): - # All these options are default False. - # If new options violate this assumption, - # this test may need to be tweaked. + # Most options are default False. # New options should follow the dash-case/snake_case convention. opt_str_to_attr_name = { name: re.sub(r"-", "_", name) @@ -161,3 +159,18 @@ def test_options_bool_flags(): options = Options.build(opt) assert getattr(options, attr) + + # Check autogen-snippets separately, as it is default True + options = Options.build("") + assert options.autogen_snippets + + options = Options.build("autogen-snippets=False") + assert not options.autogen_snippets + + +def test_options_autogen_snippets_false_for_old_naming(): + # NOTE: Snippets are not currently correct for the alternative (Ads) templates + # so always disable snippetgen in that case + # https://github.com/googleapis/gapic-generator-python/issues/1052 + options = Options.build("old-naming") + assert not options.autogen_snippets From 1214b1e46a84e81be4059fef1b83339fba4a928e Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Tue, 2 Nov 2021 16:34:08 +0000 Subject: [PATCH 2/2] test: check old-naming + autogen-snippets=True calse --- tests/unit/generator/test_options.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/generator/test_options.py b/tests/unit/generator/test_options.py index 44df9a92a6..eaa12c9714 100644 --- a/tests/unit/generator/test_options.py +++ b/tests/unit/generator/test_options.py @@ -174,3 +174,7 @@ def test_options_autogen_snippets_false_for_old_naming(): # https://github.com/googleapis/gapic-generator-python/issues/1052 options = Options.build("old-naming") assert not options.autogen_snippets + + # Even if autogen-snippets is set to True, do not enable snippetgen + options = Options.build("old-naming,autogen-snippets=True") + assert not options.autogen_snippets