File: test_cli_compile.py

package info (click to toggle)
sphinx-theme-builder 0.2.0b2-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 448 kB
  • sloc: python: 2,227; sh: 19; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from unittest import mock

from click import Group
from click.testing import CliRunner


class TestCompileCommand:
    """`stb compile`"""

    def test_calls_generate_assets(self, runner: CliRunner, cli: Group) -> None:
        with mock.patch(
            "sphinx_theme_builder._internal.cli.compile.generate_assets"
        ) as mocked_generate_assets, mock.patch(
            "sphinx_theme_builder._internal.cli.compile.Project"
        ) as mocked_project:
            with runner.isolated_filesystem():
                process = runner.invoke(cli, ["compile"])

        assert process.exit_code == 0, process

        mocked_generate_assets.assert_has_calls(
            [
                mock.call(mocked_project.from_cwd(), production=False),
            ]
        )

    def test_calls_generate_assets_in_production(
        self, runner: CliRunner, cli: Group
    ) -> None:
        with mock.patch(
            "sphinx_theme_builder._internal.cli.compile.generate_assets"
        ) as mocked_generate_assets, mock.patch(
            "sphinx_theme_builder._internal.cli.compile.Project"
        ) as mocked_project:
            with runner.isolated_filesystem():
                process = runner.invoke(cli, ["compile", "--production"])

        assert process.exit_code == 0, process

        mocked_generate_assets.assert_has_calls(
            [
                mock.call(mocked_project.from_cwd(), production=True),
            ]
        )