mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Generate an uuid for compute node if None is provided
This commit is contained in:
5 files changed
+51
-18
No files matched your search
@@ -47,9 +47,10 @@ def test_name():
|
||||
assert c.name == "Local"
|
||||
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(), name="hello")
|
||||
assert c.name == "hello"
|
||||
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(),user="azertyuiopqsdfghjklkm")
|
||||
c = Compute("world", protocol="https", host="example.com", port=84, controller=MagicMock(), user="azertyuiopqsdfghjklkm")
|
||||
assert c.name == "https://azertyuiopq...@example.com:84"
|
||||
|
||||
|
||||
def test_compute_local(compute):
|
||||
"""
|
||||
If the compute is local but the compute id is local
|
||||
|
||||
@@ -77,27 +77,30 @@ def test_isEnabled(controller):
|
||||
|
||||
def test_addCompute(controller, controller_config_path, async_run):
|
||||
controller._notification = MagicMock()
|
||||
c = async_run(controller.add_compute("test1"))
|
||||
c = async_run(controller.add_compute(compute_id="test1"))
|
||||
controller._notification.emit.assert_called_with("compute.created", c.__json__())
|
||||
assert len(controller.computes) == 1
|
||||
async_run(controller.add_compute("test1"))
|
||||
async_run(controller.add_compute(compute_id="test1"))
|
||||
controller._notification.emit.assert_called_with("compute.updated", c.__json__())
|
||||
assert len(controller.computes) == 1
|
||||
async_run(controller.add_compute("test2"))
|
||||
async_run(controller.add_compute(compute_id="test2"))
|
||||
assert len(controller.computes) == 2
|
||||
|
||||
|
||||
def test_deleteCompute(controller, controller_config_path, async_run):
|
||||
c = async_run(controller.add_compute("test1"))
|
||||
c = async_run(controller.add_compute(compute_id="test1"))
|
||||
assert len(controller.computes) == 1
|
||||
controller._notification = MagicMock()
|
||||
async_run(controller.delete_compute("test1"))
|
||||
assert len(controller.computes) == 0
|
||||
controller._notification.emit.assert_called_with("compute.deleted", c.__json__())
|
||||
with open(controller_config_path) as f:
|
||||
data = json.load(f)
|
||||
assert len(data["computes"]) == 0
|
||||
|
||||
|
||||
def test_addComputeConfigFile(controller, controller_config_path, async_run):
|
||||
async_run(controller.add_compute("test1"))
|
||||
async_run(controller.add_compute(compute_id="test1"))
|
||||
assert len(controller.computes) == 1
|
||||
with open(controller_config_path) as f:
|
||||
data = json.load(f)
|
||||
@@ -105,7 +108,7 @@ def test_addComputeConfigFile(controller, controller_config_path, async_run):
|
||||
{
|
||||
'compute_id': 'test1',
|
||||
'host': 'localhost',
|
||||
'port': 8000,
|
||||
'port': 3080,
|
||||
'protocol': 'http',
|
||||
'user': None,
|
||||
'password': None
|
||||
@@ -114,7 +117,7 @@ def test_addComputeConfigFile(controller, controller_config_path, async_run):
|
||||
|
||||
|
||||
def test_getCompute(controller, async_run):
|
||||
compute = async_run(controller.add_compute("test1"))
|
||||
compute = async_run(controller.add_compute(compute_id="test1"))
|
||||
|
||||
assert controller.get_compute("test1") == compute
|
||||
with pytest.raises(aiohttp.web.HTTPNotFound):
|
||||
|
||||
@@ -16,7 +16,27 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
def test_compute_create(http_controller, controller):
|
||||
def test_compute_create_without_id(http_controller, controller):
|
||||
|
||||
params = {
|
||||
"protocol": "http",
|
||||
"host": "example.com",
|
||||
"port": 84,
|
||||
"user": "julien",
|
||||
"password": "secure"
|
||||
}
|
||||
response = http_controller.post("/computes", params, example=True)
|
||||
assert response.status == 201
|
||||
assert response.route == "/computes"
|
||||
assert response.json["user"] == "julien"
|
||||
assert response.json["compute_id"] is not None
|
||||
assert "password" not in response.json
|
||||
|
||||
assert len(controller.computes) == 1
|
||||
assert controller.computes[response.json["compute_id"]].host == "example.com"
|
||||
|
||||
|
||||
def test_compute_create_with_id(http_controller, controller):
|
||||
|
||||
params = {
|
||||
"compute_id": "my_compute_id",
|
||||
@@ -36,6 +56,7 @@ def test_compute_create(http_controller, controller):
|
||||
assert controller.computes["my_compute_id"].host == "example.com"
|
||||
|
||||
|
||||
|
||||
def test_compute_get(http_controller, controller):
|
||||
|
||||
params = {
|
||||
|
||||
Reference in new issue
Block a user