Commit 16495c39 by Arun Babu Neelicattu

test: improve coverage for show with group options

parent cbee6649
......@@ -101,6 +101,174 @@ pytest 3.7.3 Pytest package
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
):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment