Return a compute name it could be different of compute id

This commit is contained in:
Julien Duponchelle committed 2016-05-23 11:27:47 +02:00
1 parent 3e6aec016b
commit f6a3899603
6 files changed
+48 -5

No files matched your search

+11
View File
@@ -39,6 +39,16 @@ def test_init(compute):
assert compute.id == "my_compute_id"
def test_name():
c = Compute("my_compute_id", protocol="https", host="example.com", port=84, controller=MagicMock(), name=None)
assert c.name == "https://example.com:84"
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
c = Compute("local", protocol="https", host="example.com", port=84, controller=MagicMock(), name=None)
assert c.name == "local"
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(), name="hello")
assert c.name == "hello"
def test_compute_local(compute):
"""
If the compute is local but the compute id is local
@@ -174,6 +184,7 @@ def test_json(compute):
compute.user = "test"
assert compute.__json__() == {
"compute_id": "my_compute_id",
"name": compute.name,
"protocol": "https",
"host": "example.com",
"port": 84,
+2 -1
View File
@@ -63,7 +63,8 @@ def test_load(controller, controller_config_path, async_run):
"host": "localhost",
"port": 8000,
"protocol": "http",
"user": "admin"
"user": "admin",
"name": "http://localhost:8000"
}
@@ -62,7 +62,8 @@ def test_compute_list(http_controller, controller):
"host": "example.com",
"port": 84,
"user": "julien",
"password": "secure"
"password": "secure",
"name": "My super server"
}
response = http_controller.post("/computes", params)
assert response.status == 201
@@ -78,6 +79,8 @@ def test_compute_list(http_controller, controller):
'host': 'example.com',
'port': 84,
'protocol': 'http',
'user': 'julien'
'user': 'julien',
'name': 'My super server'
}
]