Skip to content

Commit

Permalink
Tests: Add tests for instance reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
csadorf committed Feb 14, 2022
1 parent e381d6a commit 94781e1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
This is the test module for the project's command-line interface (CLI)
module.
"""
import docker
import pytest
from click.testing import CliRunner, Result

Expand Down Expand Up @@ -162,17 +163,39 @@ def test_remove_running_profile(self):
@pytest.mark.slow
@pytest.mark.trylast
class TestInstanceLifecycle:
def test_start_stop(self, instance):
def test_start_stop_reset(self, instance, docker_client):
runner: CliRunner = CliRunner()
result: Result = runner.invoke(
cli.cli, ["-vvv", "start", "--no-browser", "--wait=300"]
)
assert result.exit_code == 0
result: Result = runner.invoke(cli.cli, ["status"])
assert result.exit_code == 0

# Should not throw:
docker_client.volumes.get(instance.profile.home_mount)
docker_client.volumes.get(instance.profile.conda_volume_name())

result: Result = runner.invoke(cli.cli, ["stop", "--remove"])
assert result.exit_code == 0
result: Result = runner.invoke(cli.cli, ["status"])
assert result.exit_code == 0
assert instance.profile.container_name() in result.output
assert "down" in result.output

# Should not throw:
docker_client.volumes.get(instance.profile.home_mount)

with pytest.raises(docker.errors.NotFound):
docker_client.volumes.get(instance.profile.conda_volume_name())

result: Result = runner.invoke(
cli.cli, ["reset"], input=f"{instance.profile.name}\n"
)
assert result.exit_code == 0
# result: Result = runner.invoke(cli.cli, ["reset", "--apps"]) # xfail

with pytest.raises(docker.errors.NotFound):
docker_client.volumes.get(instance.profile.home_mount)
with pytest.raises(docker.errors.NotFound):
docker_client.volumes.get(instance.profile.conda_volume_name())

0 comments on commit 94781e1

Please sign in to comment.