mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
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:
5 files changed
+68
-13
No files matched your search
@@ -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")
|
||||
Reference in new issue
Block a user