-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024-present Plone Foundation <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
__version__ = "0.5.2" | ||
__version__ = "0.5.3.dev0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix parsing of extra_context via cli [@ericof] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
from click.exceptions import BadParameter | ||
|
||
from cookieplone import cli | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value,expected", | ||
[ | ||
([], {}), | ||
(["foo=bar", "bar=bar"], {"foo": "bar", "bar": "bar"}), | ||
(["foo=1", "bar=2"], {"foo": "1", "bar": "2"}), | ||
], | ||
) | ||
def test_parse_extra_content(value: list[str], expected: dict): | ||
func = cli.parse_extra_content | ||
assert func(value) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value,expected", | ||
[ | ||
(None, []), | ||
([], []), | ||
(["foo=bar", "bar=bar"], ["foo=bar", "bar=bar"]), | ||
(["foo=1", "bar=2"], ["foo=1", "bar=2"]), | ||
], | ||
) | ||
def test_validate_extra_context_pass(value: list[str] | None, expected: list): | ||
func = cli.validate_extra_context | ||
assert func(value) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value,expected", | ||
[ | ||
(["foo=bar", "bar2"], "bar2"), | ||
(["foo-1", "bar=2"], "foo-1"), | ||
], | ||
) | ||
def test_validate_extra_context_fail(value: list[str] | None, expected: str): | ||
func = cli.validate_extra_context | ||
with pytest.raises(BadParameter) as exc: | ||
func(value) | ||
assert expected in str(exc) |