"""Tests for abreka.cli.stop_cmd."""

import os

from click.testing import CliRunner

from abreka.cli import main


class TestStopCommand:
    def test_after_current_creates_stop_request_file(self, abreka_project):
        runner = CliRunner()
        os.chdir(abreka_project)

        result = runner.invoke(main, ["stop", "--after-current"])

        assert result.exit_code == 0, result.output
        assert (abreka_project / "abreka" / ".stop_after_current").is_file()
        assert "after the current experiment completes" in result.output

    def test_requires_after_current_flag(self, abreka_project):
        runner = CliRunner()
        os.chdir(abreka_project)

        result = runner.invoke(main, ["stop"])

        assert result.exit_code != 0
        assert "Specify --after-current" in result.output
