Skip to content

Commit 185ecc7

Browse files
authored
test: add tests for autogen-snippets option (#1055)
Follow up to #1044
1 parent d85dfad commit 185ecc7

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tests/unit/generator/test_options.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def test_options_service_config(fs):
141141

142142

143143
def test_options_bool_flags():
144-
# All these options are default False.
145-
# If new options violate this assumption,
146-
# this test may need to be tweaked.
144+
# Most options are default False.
147145
# New options should follow the dash-case/snake_case convention.
148146
opt_str_to_attr_name = {
149147
name: re.sub(r"-", "_", name)
@@ -161,3 +159,22 @@ def test_options_bool_flags():
161159

162160
options = Options.build(opt)
163161
assert getattr(options, attr)
162+
163+
# Check autogen-snippets separately, as it is default True
164+
options = Options.build("")
165+
assert options.autogen_snippets
166+
167+
options = Options.build("autogen-snippets=False")
168+
assert not options.autogen_snippets
169+
170+
171+
def test_options_autogen_snippets_false_for_old_naming():
172+
# NOTE: Snippets are not currently correct for the alternative (Ads) templates
173+
# so always disable snippetgen in that case
174+
# https://github.com/googleapis/gapic-generator-python/issues/1052
175+
options = Options.build("old-naming")
176+
assert not options.autogen_snippets
177+
178+
# Even if autogen-snippets is set to True, do not enable snippetgen
179+
options = Options.build("old-naming,autogen-snippets=True")
180+
assert not options.autogen_snippets

0 commit comments

Comments
 (0)