mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-02-06 19:19:15 +00:00
parent
a8ffaa9cb5
commit
dd849f7945
@ -15,6 +15,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import re
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
@ -282,6 +283,7 @@ class Project:
|
|||||||
|
|
||||||
if base_name is None:
|
if base_name is None:
|
||||||
return None
|
return None
|
||||||
|
base_name = re.sub(r"[ ]", "", base_name)
|
||||||
self.remove_allocated_node_name(base_name)
|
self.remove_allocated_node_name(base_name)
|
||||||
if '{0}' in base_name or '{id}' in base_name:
|
if '{0}' in base_name or '{id}' in base_name:
|
||||||
# base name is a template, replace {0} or {id} by an unique identifier
|
# base name is a template, replace {0} or {id} by an unique identifier
|
||||||
|
@ -539,3 +539,20 @@ def test_suspend_all(project, async_run):
|
|||||||
compute.post = AsyncioMagicMock()
|
compute.post = AsyncioMagicMock()
|
||||||
async_run(project.suspend_all())
|
async_run(project.suspend_all())
|
||||||
assert len(compute.post.call_args_list) == 10
|
assert len(compute.post.call_args_list) == 10
|
||||||
|
|
||||||
|
|
||||||
|
def test_node_name(project, async_run):
|
||||||
|
compute = MagicMock()
|
||||||
|
compute.id = "local"
|
||||||
|
response = MagicMock()
|
||||||
|
response.json = {"console": 2048}
|
||||||
|
compute.post = AsyncioMagicMock(return_value=response)
|
||||||
|
|
||||||
|
node = async_run(project.add_node(compute, "test-{0}", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||||
|
assert node.name == "test-1"
|
||||||
|
node = async_run(project.add_node(compute, "test-{0}", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||||
|
assert node.name == "test-2"
|
||||||
|
node = async_run(project.add_node(compute, "hello world-{0}", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||||
|
assert node.name == "helloworld-1"
|
||||||
|
node = async_run(project.add_node(compute, "hello world-{0}", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||||
|
assert node.name == "helloworld-2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user