Skip to content

Commit

Permalink
test: improve coverage for show with group options
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Mar 23, 2022
1 parent 399c650 commit 83206ca
Showing 1 changed file with 168 additions and 0 deletions.
168 changes: 168 additions & 0 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,174 @@ def test_show_basic_with_installed_packages(
assert tester.io.fetch_output() == expected


def _configure_project_with_groups(poetry: Poetry, installed: Repository) -> None:
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))

poetry.package.add_dependency_group(DependencyGroup(name="time", optional=True))
poetry.package.add_dependency(
Factory.create_dependency("pendulum", "^2.0.0", groups=["time"])
)

poetry.package.add_dependency(
Factory.create_dependency("pytest", "^3.7.3", groups=["test"])
)

cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package"

pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package"
pendulum_200.category = "dev"

pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package"
pytest_373.category = "dev"

installed.add_package(cachy_010)
installed.add_package(pendulum_200)
installed.add_package(pytest_373)

poetry.locker.mock_lock_data(
{
"package": [
{
"name": "cachy",
"version": "0.1.0",
"description": "Cachy package",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
{
"name": "pendulum",
"version": "2.0.0",
"description": "Pendulum package",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
{
"name": "pytest",
"version": "3.7.3",
"description": "Pytest package",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "pytest": []},
},
}
)


@pytest.mark.parametrize(
("options", "expected"),
[
(
"",
"""\
cachy 0.1.0 Cachy package
pytest 3.7.3 Pytest package
""",
),
(
"--with time",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package
""",
),
(
"--without test",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--without default",
"""\
pytest 3.7.3 Pytest package
""",
),
(
"--only default",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--default",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--no-dev",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--with time --without test",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
""",
),
(
"--with time --without default,test",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--only time",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--only time --with test",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--with time",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package
""",
),
],
)
def test_show_basic_with_group_options(
options: str,
expected: str,
tester: CommandTester,
poetry: Poetry,
installed: Repository,
):
_configure_project_with_groups(poetry, installed)

tester.execute(options)

assert tester.io.fetch_output() == expected


def test_show_basic_with_installed_packages_single(
tester: CommandTester, poetry: Poetry, installed: Repository
):
Expand Down

0 comments on commit 83206ca

Please sign in to comment.