Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sdcore_config interface tests #171

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interfaces/sdcore_config/v0/interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: sdcore_config
internal: true

version: 0
status: draft
status: published

providers:
- name: sdcore-nms-k8s
Expand Down
50 changes: 11 additions & 39 deletions interfaces/sdcore_config/v0/interface_tests/test_provider.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
# Copyright 2024 Canonical
# See LICENSE file for licensing details.

from interface_tester.interface_test import Tester
from interface_tester import Tester
from scenario import State, Relation
import json


def test_data_published_on_created():
t = Tester(
State(
relations=[
Relation(
endpoint="sdcore_config",
interface="sdcore_config",
)
],
)
)
state_out: State = t.run("sdcore-config-relation-created")
t.assert_schema_valid()
assert state_out.unit_status.name == 'active'
def test_no_data_on_created():
t = Tester()
t.run("sdcore-config-relation-created")
t.assert_relation_data_empty()


def test_data_published_on_joined():
def test_data_published_on_created():
t = Tester(
State(
relations=[
Expand All @@ -32,12 +23,11 @@ def test_data_published_on_joined():
],
)
)
state_out: State = t.run("sdcore-config-relation-joined")
t.assert_schema_valid()
assert state_out.unit_status.name == 'active'
t.run("sdcore-config-relation-created")
t.assert_relation_data_empty()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks more like a test_no_data_on_created



def test_data_published_on_changed():
def test_data_published_on_joined():
t = Tester(
State(
relations=[
Expand All @@ -48,23 +38,5 @@ def test_data_published_on_changed():
],
)
)
state_out: State = t.run("sdcore-config-relation-changed")
t.run("sdcore-config-relation-joined")
t.assert_schema_valid()
assert state_out.unit_status.name == 'active'


def test_no_data_on_broken():
t = Tester(
State(
relations=[
Relation(
endpoint="sdcore_config",
interface="sdcore_config",
)
],
)
)
state_out: State = t.run("sdcore-config-relation-broken")
t.assert_relation_data_empty()
assert state_out.unit_status.name == 'active'

24 changes: 4 additions & 20 deletions interfaces/sdcore_config/v0/interface_tests/test_requirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,17 @@
from scenario import Relation, State


def test_state_active_on_joined():
def test_no_data_on_joined():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a 'happy-path' test in here too, one where you t.assert_schema_valid().

t = Tester(
State(
relations=[
Relation(
endpoint="sdcore_config",
interface="sdcore_config",
remote_app_data={"webui_url": "some_url:123"},
)
],
)
)
state_out: State = t.run('sdcore-config-relation-joined')
assert state_out.unit_status.name == 'active'


def test_state_blocked_on_broken():
t = Tester(
State(
relations=[
Relation(
endpoint="sdcore_config",
interface="sdcore_config",
)
],
)
)
state_out: State = t.run('sdcore-config-relation-broken')
assert state_out.unit_status.name == 'blocked'


t.run('sdcore-config-relation-joined')
t.assert_relation_data_empty()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised this would pass, since you are putting some data in the input state. Is the charm supposed to delete the data? If so, rename the test to something more explicit or add some comments to explain what's going on.

Loading