-
Notifications
You must be signed in to change notification settings - Fork 27
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
1 parent
1f18a84
commit 07f3159
Showing
4 changed files
with
23 additions
and
6 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
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import pytest | ||
from models_library.projects_nodes_ui import Marker | ||
from pydantic_extra_types.color import Color | ||
|
||
|
||
def test_marker_serialization(): | ||
m = Marker(color=Color("#b7e28d")) | ||
|
||
assert m.model_dump_json() == '{"color":"#b7e28d"}' | ||
@pytest.mark.parametrize( | ||
"color_str,expected_color_str", [("#b7e28d", "#b7e28d"), ("Cyan", "#0ff")] | ||
) | ||
def test_marker_color_serialized_to_hex(color_str, expected_color_str): | ||
m = Marker(color=Color(color_str)) | ||
assert m.model_dump_json() == f'{{"color":"{expected_color_str}"}}' |
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,14 @@ | ||
import pytest | ||
from models_library.projects_ui import Annotation | ||
from pydantic_extra_types.color import Color | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"color_str,expected_color_str", [("#b7e28d", "#b7e28d"), ("Cyan", "#0ff")] | ||
) | ||
def test_annotation_color_serialized_to_hex(color_str, expected_color_str): | ||
m = Annotation(type="text", color=Color(color_str), attributes={}) | ||
assert ( | ||
m.model_dump_json() | ||
== f'{{"type":"text","color":"{expected_color_str}","attributes":{{}}}}' | ||
) |