|
6 | 6 | _audit_exclude_missing_export,
|
7 | 7 | _audit_exclude_missing_public,
|
8 | 8 | _audit_exclude_missing_rst,
|
| 9 | + check, |
9 | 10 | )
|
10 | 11 | from automation.docstring_lint.public_api_validator import PublicSymbol
|
| 12 | +from click.testing import CliRunner |
11 | 13 |
|
12 | 14 |
|
13 | 15 | class TestAuditExcludeMissingPublic:
|
@@ -270,3 +272,120 @@ def test_audit_missing_export_calls_validator_correctly(self):
|
270 | 272 | mock_validator.find_public_symbols.assert_called_once_with(
|
271 | 273 | exclude_modules={"excluded.module"}
|
272 | 274 | )
|
| 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