Skip to content

Commit f4eb722

Browse files
committed
Fix mock_connect_model return values in unit tests
1 parent ee0cd22 commit f4eb722

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tests/unit/test_model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,23 @@ class TestModelConnect(asynctest.TestCase):
170170
@pytest.mark.asyncio
171171
async def test_no_args(self, mock_connect_model, _):
172172
m = Model()
173+
mock_connect_model.side_effect = [("_", "uuid")]
173174
await m.connect()
174175
mock_connect_model.assert_called_once_with(None)
175176

176177
@asynctest.patch('juju.client.connector.Connector.connect_model')
177178
@pytest.mark.asyncio
178179
async def test_with_model_name(self, mock_connect_model, _):
179180
m = Model()
181+
mock_connect_model.side_effect = [("_", "uuid")]
180182
await m.connect(model_name='foo')
181183
mock_connect_model.assert_called_once_with('foo')
182184

183185
@asynctest.patch('juju.client.connector.Connector.connect_model')
184186
@pytest.mark.asyncio
185187
async def test_with_endpoint_but_no_uuid(self, mock_connect_model, _):
186188
m = Model()
189+
mock_connect_model.side_effect = [("_", "uuid")]
187190
with self.assertRaises(TypeError):
188191
await m.connect(endpoint='0.1.2.3:4566')
189192
self.assertEqual(mock_connect_model.call_count, 0)
@@ -251,6 +254,7 @@ async def test_with_endpoint_and_uuid_with_macaroon(self, mock_connect, _):
251254
@asynctest.patch('juju.client.connector.Connector.connect')
252255
async def test_with_posargs(self, mock_connect, mock_connect_model, _):
253256
m = Model()
257+
mock_connect_model.side_effect = [("_", "uuid")]
254258
await m.connect('foo')
255259
mock_connect_model.assert_called_once_with('foo')
256260
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)