Skip to content

Commit

Permalink
monitor: make origin a setter
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 authored and ondrejbudai committed Mar 12, 2024
1 parent 27ac6dd commit dd57546
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions osbuild/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ def with_origin(self, origin: Optional[str]) -> "Context":
if origin is None or origin == self._origin:
return self
ctx = copy.copy(self)
ctx.set_origin(origin)
ctx.origin = origin
return ctx

@property
def origin(self):
return self._origin

def set_origin(self, origin: str):
@origin.setter
def origin(self, origin: str):
self._origin = origin

@property
Expand Down
4 changes: 2 additions & 2 deletions test/mod/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def test_context():
assert ctx_dict["id"] == "75bf3feab3d5662744c3ac38406ba73142aeb67666b1180bc1006f913b18f792"
assert len(ctx_dict) == 1

ctx.set_origin("org.osbuild.test-2")
ctx.origin = "org.osbuild.test-2"
ctx_dict = ctx.as_dict()
# should be a full dict again
assert "origin" in ctx_dict
assert "pipeline" in ctx_dict
assert ctx_dict["pipeline"]["name"] == "test-pipeline"
assert ctx_dict["pipeline"]["stage"]["name"] == "org.osbuild.noop"

ctx.set_origin("org.osbuild.test")
ctx.origin = "org.osbuild.test"
ctx_dict = ctx.as_dict()
# should only have id again (old context ID)
assert ctx_dict["id"] == "75bf3feab3d5662744c3ac38406ba73142aeb67666b1180bc1006f913b18f792"
Expand Down

0 comments on commit dd57546

Please sign in to comment.