@@ -72,17 +72,20 @@ def fake_granular_env_file_content() -> str:
7272
7373
7474def test_compose_commands (cli : typer .Typer , cli_runner : CliRunner ):
75- result = cli_runner .invoke (cli , ["--help" ])
75+ # NOTE: this tests is mostly here to raise awareness about what options
76+ # are exposed in the CLI so we can add tests if there is any update
77+ #
78+ result = cli_runner .invoke (cli , ["--help" ], catch_exceptions = False )
7679 print (result .stdout )
7780 assert result .exit_code == 0 , result
7881
7982 # first command
80- result = cli_runner .invoke (cli , ["run" , "--help" ])
83+ result = cli_runner .invoke (cli , ["run" , "--help" ], catch_exceptions = False )
8184 print (result .stdout )
8285 assert result .exit_code == 0 , result
8386
8487 # settings command
85- result = cli_runner .invoke (cli , ["settings" , "--help" ])
88+ result = cli_runner .invoke (cli , ["settings" , "--help" ], catch_exceptions = False )
8689 print (result .stdout )
8790
8891 assert "--compact" in result .stdout
@@ -96,34 +99,58 @@ def extract_lines(text):
9699
97100
98101HELP = """
99- Usage: app settings [OPTIONS]
100-
101- Resolves settings and prints envfile
102-
103- Options:
104- --as-json / --no-as-json [default: no-as-json]
105- --as-json-schema / --no-as-json-schema
106- [default: no-as-json-schema]
107- --compact / --no-compact Print compact form [default: no-compact]
108- --verbose / --no-verbose [default: no-verbose]
109- --show-secrets / --no-show-secrets
110- [default: no-show-secrets]
111- --help Show this message and exit.
102+ Usage: app settings [OPTIONS]
103+
104+ Resolves settings and prints envfile
105+
106+ Options:
107+ --as-json / --no-as-json [default: no-as-json]
108+ --as-json-schema / --no-as-json-schema
109+ [default: no-as-json-schema]
110+ --compact / --no-compact Print compact form [default: no-compact]
111+ --verbose / --no-verbose [default: no-verbose]
112+ --show-secrets / --no-show-secrets
113+ [default: no-show-secrets]
114+ --exclude-unset / --no-exclude-unset
115+ displays settings that were explicitly setThis
116+ represents current config (i.e. required+
117+ defaults overriden). [default: no-exclude-
118+ unset]
119+ --help Show this message and exit.
112120"""
113121
114122
115123def test_settings_as_json (
116- cli : typer .Typer , fake_settings_class , mock_environment , cli_runner : CliRunner
124+ cli : typer .Typer ,
125+ fake_settings_class : Type [BaseCustomSettings ],
126+ mock_environment ,
127+ cli_runner : CliRunner ,
117128):
118129
119- result = cli_runner .invoke (cli , ["settings" , "--as-json" ])
130+ result = cli_runner .invoke (cli , ["settings" , "--as-json" ], catch_exceptions = False )
120131 print (result .stdout )
121132
122133 # reuse resulting json to build settings
123134 settings : Dict = json .loads (result .stdout )
124135 assert fake_settings_class .parse_obj (settings )
125136
126137
138+ def test_settings_as_json_schema (
139+ cli : typer .Typer ,
140+ fake_settings_class : Type [BaseCustomSettings ],
141+ mock_environment ,
142+ cli_runner : CliRunner ,
143+ ):
144+
145+ result = cli_runner .invoke (
146+ cli , ["settings" , "--as-json-schema" ], catch_exceptions = False
147+ )
148+ print (result .stdout )
149+
150+ # reuse resulting json to build settings
151+ settings_schema : Dict = json .loads (result .stdout )
152+
153+
127154def test_cli_default_settings_envs (
128155 cli : typer .Typer ,
129156 fake_settings_class : Type [BaseCustomSettings ],
@@ -139,6 +166,7 @@ def test_cli_default_settings_envs(
139166 cli_settings_output = cli_runner .invoke (
140167 cli ,
141168 ["settings" , "--show-secrets" ],
169+ catch_exceptions = False ,
142170 ).stdout
143171
144172 # now let's use these as env vars
@@ -207,6 +235,7 @@ def test_cli_compact_settings_envs(
207235 setting_env_content_compact = cli_runner .invoke (
208236 cli ,
209237 ["settings" , "--compact" ],
238+ catch_exceptions = False ,
210239 ).stdout
211240
212241 # now we use these as env vars
0 commit comments