Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti committed Dec 4, 2024
1 parent 2a6f82e commit e814e41
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
4 changes: 2 additions & 2 deletions interfaces/grafana_datasource_exchange/v0/interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ status: draft
providers:
- name: tempo-coordinator-k8s
url: https://github.com/canonical/tempo-coordinator-k8s-operator
branch: grafana_datasource_exchange
branch: datasource_exchange
test_setup:
location: tests/interface/conftest.py
identifier: grafana_datasource_exchange_tester

requirers:
- name: tempo-coordinator-k8s
url: https://github.com/canonical/tempo-coordinator-k8s-operator
branch: grafana_datasource_exchange
branch: datasource_exchange
test_setup:
location: tests/interface/conftest.py
identifier: grafana_datasource_exchange_tester
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,18 @@


def test_datasource_exchange():
# GIVEN the grafana_datasource interface has shared one or more sourdce UID
source = Relation(
endpoint='grafana-source',
interface='grafana_datasource',
remote_app_name='foo',
local_app_data={"grafana_source_data": json.dumps(
{"model": "somemodel", "model_uuid": "0000-0000-0000-0042", "application": "myapp",
"type": "prometheus", })},
local_unit_data={"grafana_source_host": "somehost:80"},
remote_app_data={"datasource_uids": json.dumps({
"foo/0": "myuid0",
"foo/4": "myuid1"
})}
)
# GIVEN the grafana_datasource interface has shared one or more source UIDs
source_exchange = Relation(
endpoint='grafana-source-exchange',
interface='grafana_datasource_exchange',
remote_app_name='bar'
)
tester = Tester(state_in=State(
relations=[
source,
source_exchange
]
))
# WHEN the provider processes any relation event
tester.run('grafana-source-relation-changed')
# THEN the provider publishes valid datasource-exchange data
tester.run('grafana-source-exchange-relation-changed')
# THEN the provider publishes valid data
tester.assert_schema_valid()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface_tests = [
"pytest>=7.3.1",
"ops-scenario>=7.0.5",
"requests==2.28.1",
"virtualenv==20.25.1"
"virtualenv==20.25.1",
]

[project.urls]
Expand Down

0 comments on commit e814e41

Please sign in to comment.