|
2 | 2 | from importlib import resources |
3 | 3 | from unittest import mock |
4 | 4 |
|
| 5 | +import gufe |
5 | 6 | import numpy as np |
6 | 7 | import pytest |
7 | 8 | from click.testing import CliRunner |
@@ -465,13 +466,32 @@ def test_custom_yaml_plan_radial_smoke_test(custom_yaml_radial, eg5_files, tmp_p |
465 | 466 | assert result.exit_code == 0 |
466 | 467 |
|
467 | 468 |
|
468 | | -def test_plan_rbfe_network_invalid_membrane(eg5_files): |
| 469 | +def test_plan_rbfe_invalid_membrane(eg5_files): |
469 | 470 | """eg5_protein has box vectors but no membrane. ProteinMembraneComponent validation should catch this.""" |
470 | 471 |
|
471 | | - runner = CliRunner() |
472 | 472 | args = ["--protein-membrane", eg5_files[0], "-M", eg5_files[1]] |
| 473 | + runner = CliRunner() |
| 474 | + with pytest.raises( |
| 475 | + gufe.components.errors.ComponentValidationError, |
| 476 | + match="This usually indicates missing solvent or incorrect box vectors", |
| 477 | + ): |
| 478 | + _ = runner.invoke(plan_rbfe_network, args, catch_exceptions=False) |
473 | 479 |
|
474 | | - with runner.isolated_filesystem(): |
475 | | - result = runner.invoke(plan_rbfe_network, args) |
476 | 480 |
|
477 | | - assert result.exit_code == 1 |
| 481 | +def test_plan_rbfe_missing_protein_args(eg5_files): |
| 482 | + """eg5_protein has box vectors but no membrane. ProteinMembraneComponent validation should catch this.""" |
| 483 | + args = ["-M", eg5_files[1]] |
| 484 | + |
| 485 | + runner = CliRunner(catch_exceptions=False) |
| 486 | + result = runner.invoke(plan_rbfe_network, args) |
| 487 | + assert result.exit_code == 2 |
| 488 | + assert "Either --protein or --protein-membrane must be provided." in result.stderr |
| 489 | + |
| 490 | + |
| 491 | +def test_plan_rbfe_too_many_protein_error(eg5_files): |
| 492 | + """eg5_protein has box vectors but no membrane. ProteinMembraneComponent validation should catch this.""" |
| 493 | + args = ["-M", eg5_files[1], "--protein-membrane", eg5_files[0], "-p", eg5_files[0]] |
| 494 | + |
| 495 | + runner = CliRunner(catch_exceptions=False) |
| 496 | + result = runner.invoke(plan_rbfe_network, args) |
| 497 | + assert "Only --protein (-p) or --protein-membrane may be provided, not both." in result.stderr |
0 commit comments