|
1 | 1 | """Example folder tests""" |
2 | 2 |
|
| 3 | +import shutil |
3 | 4 | from pathlib import Path |
4 | 5 |
|
| 6 | +from typer.testing import CliRunner |
| 7 | + |
| 8 | +from cppython.console.entry import app |
| 9 | + |
| 10 | +runner = CliRunner() |
5 | 11 | pytest_plugins = ['tests.fixtures.example'] |
6 | 12 |
|
7 | 13 |
|
8 | 14 | class TestExamples: |
9 | | - """Tests to apply to all examples""" |
| 15 | + """Verifies the examples are accessible""" |
10 | 16 |
|
11 | 17 | @staticmethod |
12 | 18 | def test_example_directory(example_directory: Path) -> None: |
13 | 19 | """Verify that the fixture is returning the right data""" |
14 | 20 | assert example_directory.is_dir() |
15 | 21 | assert (example_directory / 'pyproject.toml').is_file() |
| 22 | + |
| 23 | + @staticmethod |
| 24 | + def test_info(example_directory: Path) -> None: |
| 25 | + """Verifies that the info command functions with CPPython hooks""" |
| 26 | + with runner.isolated_filesystem() as temp_directory: |
| 27 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 28 | + |
| 29 | + result = runner.invoke(app, ['info']) |
| 30 | + assert result.exit_code == 0 |
| 31 | + |
| 32 | + @staticmethod |
| 33 | + def test_list(example_directory: Path) -> None: |
| 34 | + """Verifies that the list command functions with CPPython hooks""" |
| 35 | + with runner.isolated_filesystem() as temp_directory: |
| 36 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 37 | + |
| 38 | + result = runner.invoke(app, ['list']) |
| 39 | + assert result.exit_code == 0 |
| 40 | + |
| 41 | + @staticmethod |
| 42 | + def test_update(example_directory: Path) -> None: |
| 43 | + """Verifies that the update command functions with CPPython hooks""" |
| 44 | + with runner.isolated_filesystem() as temp_directory: |
| 45 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 46 | + |
| 47 | + result = runner.invoke(app, ['update']) |
| 48 | + assert result.exit_code == 0 |
| 49 | + |
| 50 | + @staticmethod |
| 51 | + def test_install(example_directory: Path) -> None: |
| 52 | + """Verifies that the install command functions with CPPython hooks""" |
| 53 | + with runner.isolated_filesystem() as temp_directory: |
| 54 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 55 | + |
| 56 | + result = runner.invoke(app, ['install']) |
| 57 | + assert result.exit_code == 0 |
0 commit comments