Skip to content

Commit

Permalink
Bug fix exit code (#329)
Browse files Browse the repository at this point in the history
* adjusted exit code and added full CLI test case

* corrected version
  • Loading branch information
mgiulini authored Aug 29, 2023
1 parent 9d5ea10 commit 0ca68c2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "arctic3d"
license = "Apache-2.0"
version = "0.1.0"
version = "0.4.1"
description = ""
authors = [
"Computational Structural Biology Group at Utrecht University <haddocking@gmail.com>",
Expand Down
4 changes: 3 additions & 1 deletion src/arctic3d/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,11 @@ def main(
)

# check if there's at least one interface
if Path(run_dir_path, "clustered_interfaces.out").is_file() is False:
if Path("clustered_interfaces.out").is_file() is False:
return 255

return 0


if __name__ == "__main__":
sys.exit(maincli())
37 changes: 37 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,40 @@ def test_cli_empty():
# remove folder
if exp_dir.exists():
shutil.rmtree(exp_dir)


def test_cli_full():
target_uniprot = "W5JXD7"
start_cwd = os.getcwd()
exit_code = main(
input_arg=target_uniprot,
db=None,
interface_file=None,
out_partner=None,
out_pdb=None,
pdb_to_use="3wqb",
chain_to_use=None,
run_dir=None,
interface_data=None,
pdb_data=None,
full=None,
ligand="no",
linkage_strategy=None,
threshold=None,
min_clust_size=1,
)
assert exit_code == 0
os.chdir(start_cwd)
exp_dir = Path(f"arctic3d-{target_uniprot}")
assert exp_dir.exists() is True
# Check that the log file has been created
assert Path(exp_dir, "arctic3d.log").exists()
# check content of the clustered interfaces file
assert Path(exp_dir, "clustered_interfaces.out").exists()
# check content of the clustered interfaces file
obs_content = Path(exp_dir, "clustered_interfaces.out").read_text()
exp_content = f"Cluster 1 -> Q9L5A4-3wqb-A{os.linesep}"
assert exp_content == obs_content
# remove folder
if exp_dir.exists():
shutil.rmtree(exp_dir)

0 comments on commit 0ca68c2

Please sign in to comment.