1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Fix computes tests

This commit is contained in:
Julien Duponchelle 2016-10-27 16:54:05 +02:00
parent 0cfdde7b7e
commit ea1c525181
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 6 additions and 2 deletions

View File

@ -145,7 +145,11 @@ class Compute:
@asyncio.coroutine @asyncio.coroutine
def update(self, **kwargs): def update(self, **kwargs):
for kw in kwargs: for kw in kwargs:
if kw not in ("user", "password"):
setattr(self, kw, kwargs[kw]) setattr(self, kw, kwargs[kw])
# It's important to set user and password at the same time
if "user" in kwargs or "password" in kwargs:
self._set_auth(kwargs.get("user", self._user), kwargs.get("password", self._password))
if self._http_session: if self._http_session:
self._http_session.close() self._http_session.close()
self._connected = False self._connected = False

View File

@ -358,7 +358,7 @@ def test_images(compute, async_run, images_dir):
open(os.path.join(images_dir, "asa.qcow2"), "w+").close() open(os.path.join(images_dir, "asa.qcow2"), "w+").close()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock: with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
images = async_run(compute.images("qemu")) images = async_run(compute.images("qemu"))
mock.assert_called_with("GET", "https://example.com:84/v2/compute/qemu/images", auth=None, data=None, headers={'content-type': 'application/json'}, chunked=False, timeout=120) mock.assert_called_with("GET", "https://example.com:84/v2/compute/qemu/images", auth=None, data=None, headers={'content-type': 'application/json'}, chunked=False, timeout=None)
assert images == [{"filename": "linux.qcow2", "path": "linux.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0}, assert images == [{"filename": "linux.qcow2", "path": "linux.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0},
{"filename": "asa.qcow2", "path": "asa.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0}] {"filename": "asa.qcow2", "path": "asa.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0}]