Raise an error if server flagged as local but should not

If the controller is not started with --local but the server ID
is local it's raise an error.
This commit is contained in:
Julien Duponchelle committed 2016-03-04 16:11:31 +01:00
1 parent aad69e9650
commit 4d77b2918e
5 files changed
+68 -13

No files matched your search

+17 -8
View File
@@ -15,9 +15,11 @@
# 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.server import Server
import pytest
from unittest.mock import patch
from gns3server.controller.server import Server, ServerError
@pytest.fixture
@@ -29,6 +31,19 @@ def test_init(server):
assert server.id == "my_server_id"
def test_server_local(server):
"""
If the server is local but the server 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 patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
s = Server("test")
def test_json(server):
assert server.__json__() == {
"server_id": "my_server_id",
@@ -40,9 +55,3 @@ def test_json(server):
"version": None
}
def test__eq__(server):
assert server != 1
assert server == server
assert server == Server("my_server_id")
assert server != Server("test")