Skip to content

Commit

Permalink
Test for HyperlinkedComponentInterfaceValueFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvanrun committed Aug 27, 2024
1 parent b9c4932 commit 48abf62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 14 additions & 6 deletions tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Algorithm,
ColorSpaceEnum,
ComponentInterface,
HyperlinkedComponentInterfaceValue,
HyperlinkedImage,
SimpleImage,
)

pk_counter = 0
Expand Down Expand Up @@ -41,15 +41,23 @@ def ComponentInterfaceFactory(**kwargs) -> ComponentInterface: # noqa: N802
return ci


def SimpleImageFactory(**kwargs) -> SimpleImage: # noqa: N802
def HyperlinkedComponentInterfaceValueFactory( # noqa: N802
**kwargs,
) -> HyperlinkedComponentInterfaceValue:
pk = kwargs.get("pk") or _get_int_pk()

pk = kwargs.get("pk") or str(uuid.uuid4())
si = SimpleImage(pk=pk, name=f"a_filename_{pk}.mha")
hciv = HyperlinkedComponentInterfaceValue(
pk=pk,
interface=ComponentInterfaceFactory(),
value=None,
file=None,
image=None,
)

for key, value in kwargs.items():
setattr(si, key, value)
setattr(hciv, key, value)

return si
return hciv


def HyperlinkedImageFactory(**kwargs) -> HyperlinkedImage: # noqa: N802
Expand Down
9 changes: 7 additions & 2 deletions tests/test_models_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from tests.factories import (
AlgorithmFactory,
ComponentInterfaceFactory,
HyperlinkedComponentInterfaceValueFactory,
HyperlinkedImageFactory,
SimpleImageFactory,
)
from tests.utils import sync_generator_test

Expand Down Expand Up @@ -170,8 +170,13 @@ def test_file_civ_validation(source, context, interface_kind):
],
nullcontext(),
),
(SimpleImageFactory(), nullcontext()),
(HyperlinkedImageFactory(), nullcontext()),
(
HyperlinkedComponentInterfaceValueFactory(
image=HyperlinkedImageFactory().api_url
),
nullcontext(),
),
),
)
@sync_generator_test
Expand Down

0 comments on commit 48abf62

Please sign in to comment.