/ tests / test_cli / conftest.py
conftest.py
 1  """Fixtures for CLI tests."""
 2  
 3  from __future__ import annotations
 4  
 5  import pathlib
 6  
 7  import pytest
 8  import typer.testing
 9  
10  from hpclb import cli, project
11  
12  
13  @pytest.fixture(scope="session")
14  def runner() -> typer.testing.CliRunner:
15      """One cli runner is enough."""
16      return typer.testing.CliRunner()
17  
18  
19  @pytest.fixture
20  def empty_project_offline(
21      tmp_path: pathlib.Path, runner: typer.testing.CliRunner
22  ) -> project.Project:
23      """Provide an initialized project with nothing else going on yet."""
24      runner.invoke(
25          cli.app, ["init", "--name", tmp_path.name, str(tmp_path), "--offline"]
26      )
27      return project.Project(tmp_path)
28  
29  
30  @pytest.fixture
31  def empty_project(
32      tmp_path: pathlib.Path, runner: typer.testing.CliRunner
33  ) -> project.Project:
34      """Provide an initialized project with nothing else going on yet."""
35      runner.invoke(cli.app, ["init", "--name", tmp_path.name, str(tmp_path)])
36      return project.Project(tmp_path)
37  
38  
39  @pytest.fixture
40  def f7ttest_project_offline(
41      empty_project_offline: project.Project, runner: typer.testing.CliRunner
42  ) -> project.Project:
43      """Provide a project with f7ttest ready to authenticate."""
44      proj = empty_project_offline
45      runner.invoke(cli.app, ["add-site", "f7ttest", str(proj.path), "--offline"])
46      return proj