Skip to content

Commit

Permalink
fix: adjust unit tests for name == entity_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Tisnek committed Sep 30, 2024
1 parent 1d6567f commit 5029d0f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/unit/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def test_expose_with_exposed_endpoints_as_raw_dict(self, mock_conn):
mock_facade().Expose.return_value.set_result([])

app = Application(entity_id="app-id", model=Model())
app.model.state.state = {"application": {"app-id": [{"name": "panther"}]}}
app._facade = mock_facade
app._facade_version = mock_facade_version

Expand All @@ -37,7 +36,7 @@ async def test_expose_with_exposed_endpoints_as_raw_dict(self, mock_conn):
})

mock_facade().Expose.assert_called_once_with(
application="panther",
application="app-id",
exposed_endpoints={
"": {
"expose-to-spaces": ["alpha"],
Expand All @@ -53,7 +52,6 @@ async def test_expose_with_exposed_endpoints(self, mock_conn):
mock_facade().Expose.return_value.set_result([])

app = Application(entity_id="app-id", model=Model())
app.model.state.state = {"application": {"app-id": [{"name": "panther"}]}}
app._facade = mock_facade
app._facade_version = mock_facade_version

Expand All @@ -67,7 +65,7 @@ async def test_expose_with_exposed_endpoints(self, mock_conn):
})

mock_facade().Expose.assert_called_once_with(
application="panther",
application="app-id",
exposed_endpoints={
"": {
"expose-to-spaces": ["alpha"],
Expand All @@ -89,7 +87,6 @@ async def test_expose_endpoints_on_older_controller(self, mock_conn):
mock_facade().Expose.return_value.set_result([])

app = Application(entity_id="app-id", model=Model())
app.model.state.state = {"application": {"app-id": [{"name": "panther"}]}}
app._facade = mock_facade
app._facade_version = mock_facade_version

Expand Down Expand Up @@ -125,7 +122,7 @@ async def test_expose_endpoints_on_older_controller(self, mock_conn):

# Check that we call the facade with the right arity.
await app.expose()
mock_facade().Expose.assert_called_once_with(application="panther")
mock_facade().Expose.assert_called_once_with(application="app-id")


class TestUnExposeApplication(unittest.IsolatedAsyncioTestCase):
Expand All @@ -137,7 +134,6 @@ async def test_unexpose_endpoints_on_older_controller(self, mock_conn):
mock_facade().Unexpose.return_value.set_result([])

app = Application(entity_id="app-id", model=Model())
app.model.state.state = {"application": {"app-id": [{"name": "panther"}]}}
app._facade = mock_facade
app._facade_version = mock_facade_version

Expand All @@ -148,7 +144,7 @@ async def test_unexpose_endpoints_on_older_controller(self, mock_conn):

# Check that we call the facade with the right arity.
await app.unexpose()
mock_facade().Unexpose.assert_called_once_with(application="panther")
mock_facade().Unexpose.assert_called_once_with(application="app-id")

@mock.patch("juju.model.Model.connection")
async def test_unexpose_endpoints_on_29_controller(self, mock_conn):
Expand All @@ -158,14 +154,13 @@ async def test_unexpose_endpoints_on_29_controller(self, mock_conn):
mock_facade().Unexpose.return_value.set_result([])

app = Application(entity_id="app-id", model=Model())
app.model.state.state = {"application": {"app-id": [{"name": "panther"}]}}
app._facade = mock_facade
app._facade_version = mock_facade_version

await app.unexpose(exposed_endpoints=["alpha", "beta"])

mock_facade().Unexpose.assert_called_once_with(
application="panther",
application="app-id",
exposed_endpoints=["alpha", "beta"]
)

Expand Down

0 comments on commit 5029d0f

Please sign in to comment.