Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Mar 30, 2023
1 parent 2308314 commit 0cd34bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions flytekit/models/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ def to_flyte_idl(self) -> _sec.Secret:

@classmethod
def from_flyte_idl(cls, pb2_object: _sec.Secret) -> "Secret":
# todo: write test for this
return cls(
group=pb2_object.group,
group_version=pb2_object.group_version if pb2_object.group_version else None,
key=pb2_object.key,
key=pb2_object.key if pb2_object.key else None,
mount_requirement=Secret.MountType(pb2_object.mount_requirement),
)

Expand Down
13 changes: 13 additions & 0 deletions tests/flytekit/unit/models/core/test_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from flytekit.models.security import Secret


def test_secret():
obj = Secret("grp", "key")
obj2 = Secret.from_flyte_idl(obj.to_flyte_idl())
assert obj2.key == "key"
assert obj2.group_version is None

obj = Secret("grp", group_version="v1")
obj2 = Secret.from_flyte_idl(obj.to_flyte_idl())
assert obj2.key is None
assert obj2.group_version == "v1"

0 comments on commit 0cd34bb

Please sign in to comment.