Skip to content

Commit

Permalink
tests: test different resources having a default
Browse files Browse the repository at this point in the history
This came up in an IRC discussion where the reporter said that this
raised some issues for him. The core library already supports this, add
a test to ensure the support stays.

Signed-off-by: Rouven Czerwinski <[email protected]>
  • Loading branch information
Emantor committed Sep 12, 2023
1 parent 2dcc631 commit 639136b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ class A(Resource):
with pytest.raises(NoResourceFoundError) as excinfo:
target.get_resource(A, name="nosuchresource")

def test_get_resource_multiple_with_default(target):
class A(Resource):
pass

class B(Resource):
pass

a = A(target, "aresource")
adef = A(target, "default")
b = B(target, "bresource")
bdef = B(target, "default")

assert target.get_resource(A) is adef
assert target.get_resource(B) is bdef
assert target.get_resource(A, name="aresource") is a
assert target.get_resource(B, name="bresource") is b

def test_get_driver(target):
class A(Driver):
pass
Expand Down

0 comments on commit 639136b

Please sign in to comment.