Skip to content

Commit 3f2eedf

Browse files
committed
tests
1 parent 6f92a6b commit 3f2eedf

File tree

2 files changed

+119
-117
lines changed

2 files changed

+119
-117
lines changed

python_modules/automation/automation_tests/docs_cli_tests/test_check_commands.py

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -209,120 +209,3 @@ def test_check_exports_no_options_fails(self):
209209
# Should fail with exit code 1
210210
assert result.exit_code == 1
211211
assert "Error: One of --all or --package must be provided" in result.output
212-
213-
214-
class TestCheckExcludeListsCommand:
215-
"""Test suite for the new exclude-lists command."""
216-
217-
def setup_method(self):
218-
"""Set up test fixtures."""
219-
self.runner = CliRunner()
220-
221-
def test_exclude_lists_no_options_fails(self):
222-
"""Test that exclude-lists command without options fails."""
223-
result = self.runner.invoke(check, ["exclude-lists"])
224-
225-
assert result.exit_code == 1
226-
assert "Error: Must specify at least one exclude list to check" in result.output
227-
228-
def test_exclude_lists_missing_public_flag(self):
229-
"""Test exclude-lists command with --missing-public flag."""
230-
result = self.runner.invoke(check, ["exclude-lists", "--missing-public"])
231-
232-
# Should complete without error (may or may not find issues)
233-
assert result.exit_code in [0, 1]
234-
assert "EXCLUDE_MISSING_PUBLIC" in result.output
235-
236-
def test_exclude_lists_missing_rst_flag(self):
237-
"""Test exclude-lists command with --missing-rst flag."""
238-
result = self.runner.invoke(check, ["exclude-lists", "--missing-rst"])
239-
240-
# Should complete without error (may or may not find issues)
241-
assert result.exit_code in [0, 1]
242-
assert "EXCLUDE_MISSING_RST" in result.output
243-
244-
def test_exclude_lists_missing_export_flag(self):
245-
"""Test exclude-lists command with --missing-export flag."""
246-
result = self.runner.invoke(check, ["exclude-lists", "--missing-export"])
247-
248-
# Should complete without error (may or may not find issues)
249-
assert result.exit_code in [0, 1]
250-
assert "EXCLUDE_MISSING_EXPORT" in result.output
251-
252-
def test_exclude_lists_all_flags_together(self):
253-
"""Test exclude-lists command with all flags together."""
254-
result = self.runner.invoke(
255-
check, ["exclude-lists", "--missing-public", "--missing-rst", "--missing-export"]
256-
)
257-
258-
# Should complete without error
259-
assert result.exit_code in [0, 1]
260-
# Should contain output from all three audits
261-
assert "EXCLUDE_MISSING_PUBLIC" in result.output
262-
assert "EXCLUDE_MISSING_RST" in result.output
263-
assert "EXCLUDE_MISSING_EXPORT" in result.output
264-
265-
def test_exclude_lists_multiple_flags_with_separators(self):
266-
"""Test that multiple flags show separator lines between outputs."""
267-
result = self.runner.invoke(check, ["exclude-lists", "--missing-public", "--missing-rst"])
268-
269-
# Should complete without error
270-
assert result.exit_code in [0, 1]
271-
# Should have separator between outputs if both ran
272-
if "EXCLUDE_MISSING_PUBLIC" in result.output and "EXCLUDE_MISSING_RST" in result.output:
273-
assert "=" * 80 in result.output
274-
275-
def test_exclude_lists_help_command(self):
276-
"""Test that exclude-lists help works."""
277-
result = self.runner.invoke(check, ["exclude-lists", "--help"])
278-
279-
assert result.exit_code == 0
280-
assert "Audit exclude lists to ensure entries are still necessary" in result.output
281-
assert "--missing-public" in result.output
282-
assert "--missing-rst" in result.output
283-
assert "--missing-export" in result.output
284-
285-
@patch("automation.docs_cli.commands.check._find_dagster_root")
286-
def test_exclude_lists_no_dagster_root(self, mock_find_dagster_root):
287-
"""Test exclude-lists command when not in dagster repository."""
288-
mock_find_dagster_root.return_value = None
289-
290-
result = self.runner.invoke(check, ["exclude-lists", "--missing-public"])
291-
292-
assert result.exit_code == 1
293-
assert "Error: Could not find dagster repository root" in result.output
294-
295-
296-
class TestCheckCommandsWithExcludeLists:
297-
"""Test suite to verify commands respect exclude lists and return clean results."""
298-
299-
def setup_method(self):
300-
"""Set up test fixtures."""
301-
self.runner = CliRunner()
302-
303-
def test_check_rst_symbols_all_with_exclude_lists(self):
304-
"""Test that check rst-symbols --all returns clean results with exclude lists."""
305-
result = self.runner.invoke(check, ["rst-symbols", "--all"])
306-
307-
# With exclude lists properly applied, should have no issues
308-
assert result.exit_code == 0, f"Command failed with output: {result.output}"
309-
assert "✓" in result.output
310-
assert "All RST documented symbols have @public decorators" in result.output
311-
312-
def test_check_public_symbols_all_with_exclude_lists(self):
313-
"""Test that check public-symbols --all returns clean results with exclude lists."""
314-
result = self.runner.invoke(check, ["public-symbols", "--all"])
315-
316-
# With exclude lists properly applied, should have no issues
317-
assert result.exit_code == 0, f"Command failed with output: {result.output}"
318-
assert "✓" in result.output
319-
assert "All @public symbols are documented in RST and exported top-level" in result.output
320-
321-
def test_check_exports_all_with_exclude_lists(self):
322-
"""Test that check exports --all returns clean results with exclude lists."""
323-
result = self.runner.invoke(check, ["exports", "--all"])
324-
325-
# With exclude lists properly applied, should have no issues
326-
assert result.exit_code == 0, f"Command failed with output: {result.output}"
327-
assert "✓" in result.output
328-
assert "All exports are properly documented and decorated" in result.output

python_modules/automation/automation_tests/docs_cli_tests/test_exclude_lists_audit.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
_audit_exclude_missing_export,
77
_audit_exclude_missing_public,
88
_audit_exclude_missing_rst,
9+
check,
910
)
1011
from automation.docstring_lint.public_api_validator import PublicSymbol
12+
from click.testing import CliRunner
1113

1214

1315
class TestAuditExcludeMissingPublic:
@@ -270,3 +272,120 @@ def test_audit_missing_export_calls_validator_correctly(self):
270272
mock_validator.find_public_symbols.assert_called_once_with(
271273
exclude_modules={"excluded.module"}
272274
)
275+
276+
277+
class TestCheckExcludeListsCommand:
278+
"""Test suite for the exclude-lists CLI command."""
279+
280+
def setup_method(self):
281+
"""Set up test fixtures."""
282+
self.runner = CliRunner()
283+
284+
def test_exclude_lists_no_options_fails(self):
285+
"""Test that exclude-lists command without options fails."""
286+
result = self.runner.invoke(check, ["exclude-lists"])
287+
288+
assert result.exit_code == 1
289+
assert "Error: Must specify at least one exclude list to check" in result.output
290+
291+
def test_exclude_lists_missing_public_flag(self):
292+
"""Test exclude-lists command with --missing-public flag."""
293+
result = self.runner.invoke(check, ["exclude-lists", "--missing-public"])
294+
295+
# Should complete without error (may or may not find issues)
296+
assert result.exit_code in [0, 1]
297+
assert "EXCLUDE_MISSING_PUBLIC" in result.output
298+
299+
def test_exclude_lists_missing_rst_flag(self):
300+
"""Test exclude-lists command with --missing-rst flag."""
301+
result = self.runner.invoke(check, ["exclude-lists", "--missing-rst"])
302+
303+
# Should complete without error (may or may not find issues)
304+
assert result.exit_code in [0, 1]
305+
assert "EXCLUDE_MISSING_RST" in result.output
306+
307+
def test_exclude_lists_missing_export_flag(self):
308+
"""Test exclude-lists command with --missing-export flag."""
309+
result = self.runner.invoke(check, ["exclude-lists", "--missing-export"])
310+
311+
# Should complete without error (may or may not find issues)
312+
assert result.exit_code in [0, 1]
313+
assert "EXCLUDE_MISSING_EXPORT" in result.output
314+
315+
def test_exclude_lists_all_flags_together(self):
316+
"""Test exclude-lists command with all flags together."""
317+
result = self.runner.invoke(
318+
check, ["exclude-lists", "--missing-public", "--missing-rst", "--missing-export"]
319+
)
320+
321+
# Should complete without error
322+
assert result.exit_code in [0, 1]
323+
# Should contain output from all three audits
324+
assert "EXCLUDE_MISSING_PUBLIC" in result.output
325+
assert "EXCLUDE_MISSING_RST" in result.output
326+
assert "EXCLUDE_MISSING_EXPORT" in result.output
327+
328+
def test_exclude_lists_multiple_flags_with_separators(self):
329+
"""Test that multiple flags show separator lines between outputs."""
330+
result = self.runner.invoke(check, ["exclude-lists", "--missing-public", "--missing-rst"])
331+
332+
# Should complete without error
333+
assert result.exit_code in [0, 1]
334+
# Should have separator between outputs if both ran
335+
if "EXCLUDE_MISSING_PUBLIC" in result.output and "EXCLUDE_MISSING_RST" in result.output:
336+
assert "=" * 80 in result.output
337+
338+
def test_exclude_lists_help_command(self):
339+
"""Test that exclude-lists help works."""
340+
result = self.runner.invoke(check, ["exclude-lists", "--help"])
341+
342+
assert result.exit_code == 0
343+
assert "Audit exclude lists to ensure entries are still necessary" in result.output
344+
assert "--missing-public" in result.output
345+
assert "--missing-rst" in result.output
346+
assert "--missing-export" in result.output
347+
348+
@patch("automation.docs_cli.commands.check._find_dagster_root")
349+
def test_exclude_lists_no_dagster_root(self, mock_find_dagster_root):
350+
"""Test exclude-lists command when not in dagster repository."""
351+
mock_find_dagster_root.return_value = None
352+
353+
result = self.runner.invoke(check, ["exclude-lists", "--missing-public"])
354+
355+
assert result.exit_code == 1
356+
assert "Error: Could not find dagster repository root" in result.output
357+
358+
359+
class TestCheckCommandsWithExcludeLists:
360+
"""Test suite to verify commands respect exclude lists and return clean results."""
361+
362+
def setup_method(self):
363+
"""Set up test fixtures."""
364+
self.runner = CliRunner()
365+
366+
def test_check_rst_symbols_all_with_exclude_lists(self):
367+
"""Test that check rst-symbols --all returns clean results with exclude lists."""
368+
result = self.runner.invoke(check, ["rst-symbols", "--all"])
369+
370+
# With exclude lists properly applied, should have no issues
371+
assert result.exit_code == 0, f"Command failed with output: {result.output}"
372+
assert "✓" in result.output
373+
assert "All RST documented symbols have @public decorators" in result.output
374+
375+
def test_check_public_symbols_all_with_exclude_lists(self):
376+
"""Test that check public-symbols --all returns clean results with exclude lists."""
377+
result = self.runner.invoke(check, ["public-symbols", "--all"])
378+
379+
# With exclude lists properly applied, should have no issues
380+
assert result.exit_code == 0, f"Command failed with output: {result.output}"
381+
assert "✓" in result.output
382+
assert "All @public symbols are documented in RST and exported top-level" in result.output
383+
384+
def test_check_exports_all_with_exclude_lists(self):
385+
"""Test that check exports --all returns clean results with exclude lists."""
386+
result = self.runner.invoke(check, ["exports", "--all"])
387+
388+
# With exclude lists properly applied, should have no issues
389+
assert result.exit_code == 0, f"Command failed with output: {result.output}"
390+
assert "✓" in result.output
391+
assert "All exports are properly documented and decorated" in result.output

0 commit comments

Comments
 (0)