-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into version-cli-tool
- Loading branch information
Showing
8 changed files
with
219 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" | |
[project] | ||
name = "ops-scenario" | ||
|
||
version = "5.2" | ||
version = "5.2.1" | ||
|
||
authors = [ | ||
{ name = "Pietro Pasotti", email = "[email protected]" } | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import pytest | ||
|
||
from scenario import Container, Event, Relation, Secret, State | ||
from scenario.state import BindFailedError | ||
|
||
|
||
def test_bind_relation(): | ||
event = Event("foo-relation-changed") | ||
foo_relation = Relation("foo") | ||
state = State(relations=[foo_relation]) | ||
assert event.bind(state).relation is foo_relation | ||
|
||
|
||
def test_bind_relation_notfound(): | ||
event = Event("foo-relation-changed") | ||
state = State(relations=[]) | ||
with pytest.raises(BindFailedError): | ||
event.bind(state) | ||
|
||
|
||
def test_bind_relation_toomany(caplog): | ||
event = Event("foo-relation-changed") | ||
foo_relation = Relation("foo") | ||
foo_relation1 = Relation("foo") | ||
state = State(relations=[foo_relation, foo_relation1]) | ||
event.bind(state) | ||
assert "too many relations" in caplog.text | ||
|
||
|
||
def test_bind_secret(): | ||
event = Event("secret-changed") | ||
secret = Secret("foo", {"a": "b"}) | ||
state = State(secrets=[secret]) | ||
assert event.bind(state).secret is secret | ||
|
||
|
||
def test_bind_secret_notfound(): | ||
event = Event("secret-changed") | ||
state = State(secrets=[]) | ||
with pytest.raises(BindFailedError): | ||
event.bind(state) | ||
|
||
|
||
def test_bind_container(): | ||
event = Event("foo-pebble-ready") | ||
container = Container("foo") | ||
state = State(containers=[container]) | ||
assert event.bind(state).container is container | ||
|
||
|
||
def test_bind_container_notfound(): | ||
event = Event("foo-pebble-ready") | ||
state = State(containers=[]) | ||
with pytest.raises(BindFailedError): | ||
event.bind(state) |
Oops, something went wrong.