Skip to content

Commit

Permalink
apply review comments, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Oct 30, 2023
1 parent 5a9649a commit a7c08f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

from cleo.helpers import option
from packaging.utils import NormalizedName
from packaging.utils import canonicalize_name
from poetry.console.commands.group_command import GroupCommand
from poetry.core.packages.dependency_group import MAIN_GROUP

from poetry_plugin_export.exporter import Exporter


if TYPE_CHECKING:
from collections.abc import Iterable


class ExportCommand(GroupCommand):
name = "export"
description = "Exports the lock file to alternative formats."
Expand Down Expand Up @@ -43,8 +49,8 @@ class ExportCommand(GroupCommand):
flag=False,
multiple=True,
),
option("with-credentials", None, "Include credentials for extra indices."),
option("all-extras", None, "Include all sets of extra dependencies."),
option("with-credentials", None, "Include credentials for extra indices."),
]

@property
Expand Down Expand Up @@ -95,6 +101,7 @@ def handle(self) -> int:
)
return 1

extras: Iterable[NormalizedName]
if self.option("all-extras"):
extras = self.poetry.package.extras.keys()
else:
Expand Down
11 changes: 11 additions & 0 deletions tests/command/test_command_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ def test_export_with_all_extras(tester: CommandTester, do_lock: None) -> None:
assert f"qux==1.2.0 ; {MARKER_PY}" in output


def test_extras_conflicts_all_extras(tester: CommandTester, do_lock: None) -> None:
tester.execute("--extras bar --all-extras")

assert tester.status_code == 1
assert (
tester.io.fetch_error()
== "You cannot specify explicit `--extras` while exporting using"
" `--all-extras`.\n"
)


def test_export_with_urls(
monkeypatch: MonkeyPatch, tester: CommandTester, poetry: Poetry
) -> None:
Expand Down

0 comments on commit a7c08f3

Please sign in to comment.