Rename /controller/servers to /controller/hypervisors

This commit is contained in:
Julien Duponchelle committed 2016-03-08 16:04:12 +01:00
1 parent 8114c1d4be
commit 6fa2491255
9 files changed
+80 -80

No files matched your search

+9 -9
View File
@@ -18,7 +18,7 @@
import pytest
from gns3server.controller import Controller
from gns3server.controller.server import Server
from gns3server.controller.hypervisor import Hypervisor
from gns3server.config import Config
@@ -29,12 +29,12 @@ def test_isEnabled(controller):
assert controller.isEnabled()
def test_addServer(controller):
server1 = Server("test1")
def test_addHypervisor(controller):
hypervisor1 = Hypervisor("test1")
controller.addServer(server1)
assert len(controller.servers) == 1
controller.addServer(Server("test1"))
assert len(controller.servers) == 1
controller.addServer(Server("test2"))
assert len(controller.servers) == 2
controller.addHypervisor(hypervisor1)
assert len(controller.hypervisors) == 1
controller.addHypervisor(Hypervisor("test1"))
assert len(controller.hypervisors) == 1
controller.addHypervisor(Hypervisor("test2"))
assert len(controller.hypervisors) == 2
@@ -19,36 +19,36 @@
import pytest
from unittest.mock import patch
from gns3server.controller.server import Server, ServerError
from gns3server.controller.hypervisor import Hypervisor, HypervisorError
from gns3server.version import __version__
@pytest.fixture
def server():
return Server("my_server_id", protocol="https", host="example.com", port=84, user="test", password="secure")
def hypervisor():
return Hypervisor("my_hypervisor_id", protocol="https", host="example.com", port=84, user="test", password="secure")
def test_init(server):
assert server.id == "my_server_id"
def test_init(hypervisor):
assert hypervisor.id == "my_hypervisor_id"
def test_server_local(server):
def test_hypervisor_local(hypervisor):
"""
If the server is local but the server id is local
If the hypervisor is local but the hypervisor id is local
it's a configuration issue
"""
with patch("gns3server.config.Config.get_section_config", return_value={"local": False}):
with pytest.raises(ServerError):
s = Server("local")
with pytest.raises(HypervisorError):
s = Hypervisor("local")
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
s = Server("test")
s = Hypervisor("test")
def test_json(server):
assert server.__json__() == {
"server_id": "my_server_id",
def test_json(hypervisor):
assert hypervisor.__json__() == {
"hypervisor_id": "my_hypervisor_id",
"protocol": "https",
"host": "example.com",
"port": 84,
@@ -16,21 +16,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
def test_server_create(http_controller, controller):
def test_hypervisor_create(http_controller, controller):
params = {
"server_id": "my_server_id",
"hypervisor_id": "my_hypervisor_id",
"protocol": "http",
"host": "example.com",
"port": 84,
"user": "julien",
"password": "secure"
}
response = http_controller.post("/servers", params, example=True)
response = http_controller.post("/hypervisors", params, example=True)
assert response.status == 201
assert response.route == "/servers"
assert response.route == "/hypervisors"
assert response.json["user"] == "julien"
assert "password" not in response.json
assert len(controller.servers) == 1
assert controller.servers["my_server_id"].host == "example.com"
assert len(controller.hypervisors) == 1
assert controller.hypervisors["my_hypervisor_id"].host == "example.com"
+1 -1
View File
@@ -39,4 +39,4 @@ def test_documentation_write(tmpdir):
assert "Sample session" in content
assert "literalinclude:: ../../../examples/hypervisor_post_projectsprojectidvirtualboxvms.txt" in content
assert os.path.exists(str(tmpdir / "api" / "v2" / "controller" / "server.rst"))
assert os.path.exists(str(tmpdir / "api" / "v2" / "controller" / "hypervisor.rst"))