gns3-server/tests/controller/gns3vm/test_remote_gns3_vm.py

72 lines
2.3 KiB
Python
Raw Normal View History

2016-08-30 08:19:01 +00:00
#!/usr/bin/env python
#
# Copyright (C) 2020 GNS3 Technologies Inc.
2016-08-30 08:19:01 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
from gns3server.controller.gns3vm.remote_gns3_vm import RemoteGNS3VM
from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError
@pytest.fixture
def gns3vm(controller):
2016-08-30 08:19:01 +00:00
return RemoteGNS3VM(controller)
async def test_list(gns3vm, controller):
await controller.add_compute("r1", name="R1", host="r1.local", connect=False)
res = await gns3vm.list()
2016-08-30 08:19:01 +00:00
assert res == [{"vmname": "R1"}]
async def test_start(gns3vm, controller):
await controller.add_compute("r1",
name="R1",
protocol="https",
host="r1.local",
port=8484,
user="hello",
password="world",
connect=False)
2016-08-30 08:19:01 +00:00
gns3vm.vmname = "R1"
await gns3vm.start()
2016-08-30 08:19:01 +00:00
assert gns3vm.running
assert gns3vm.protocol == "https"
assert gns3vm.ip_address == "r1.local"
assert gns3vm.port == 8484
assert gns3vm.user == "hello"
assert gns3vm.password == "world"
async def test_start_invalid_vm(loop, gns3vm, controller):
await controller.add_compute("r1",
name="R1",
protocol="https",
host="r1.local",
port=8484,
user="hello",
password="world")
2016-08-30 08:19:01 +00:00
gns3vm.vmname = "R2"
with pytest.raises(GNS3VMError):
await gns3vm.start()
2016-08-30 08:19:01 +00:00
assert not gns3vm.running