projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #92 from juju/bug/schemagen
[osm/N2VC.git]
/
tests
/
base.py
diff --git
a/tests/base.py
b/tests/base.py
index
382da43
..
292d04a
100644
(file)
--- a/
tests/base.py
+++ b/
tests/base.py
@@
-1,9
+1,11
@@
-import
uuid
+import
mock
import subprocess
import subprocess
+import uuid
import pytest
from juju.controller import Controller
import pytest
from juju.controller import Controller
+from juju.client.connection import JujuData
def is_bootstrapped():
def is_bootstrapped():
@@
-29,9
+31,21
@@
class CleanModel():
model_name = 'model-{}'.format(uuid.uuid4())
self.model = await self.controller.add_model(model_name)
model_name = 'model-{}'.format(uuid.uuid4())
self.model = await self.controller.add_model(model_name)
+ # Ensure that we connect to the new model by default. This also
+ # prevents failures if test was started with no current model.
+ self._patch_cm = mock.patch.object(JujuData, 'current_model',
+ return_value=model_name)
+ self._patch_cm.start()
+
return self.model
async def __aexit__(self, exc_type, exc, tb):
return self.model
async def __aexit__(self, exc_type, exc, tb):
+ self._patch_cm.stop()
await self.model.disconnect()
await self.controller.destroy_model(self.model.info.uuid)
await self.controller.disconnect()
await self.model.disconnect()
await self.controller.destroy_model(self.model.info.uuid)
await self.controller.disconnect()
+
+
+class AsyncMock(mock.MagicMock):
+ async def __call__(self, *args, **kwargs):
+ return super().__call__(*args, **kwargs)