Skip to content

Commit d673541

Browse files
authored
SIMPLE-6397 Added support for 3.0, updated obsolete controller versions (#102)
* SIMPLE-6397 Added support for 3.0, updated obsolete controller versions * Removed unrealistic test
1 parent 1796f73 commit d673541

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

tests/conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ def client_library_server_2_0_0():
4949
yield from client_library_patched_system_info(version="2.0.0")
5050

5151

52-
@pytest.fixture
53-
def client_library_server_1_0_0():
54-
yield from client_library_patched_system_info(version="1.0.0")
55-
56-
5752
@pytest.fixture
5853
def client_library_server_3_9_0():
5954
yield from client_library_patched_system_info(version="3.9.0")

tests/test_client_library.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,6 @@ def test_client_library_str_and_repr(client_library_server_current):
365365
assert str(client_library) == "ClientLibrary URL: https://somehost/api/v0/"
366366

367367

368-
def test_major_version_mismatch(client_library_server_1_0_0):
369-
with pytest.raises(InitializationError) as err:
370-
ClientLibrary("somehost", "virl2", password="virl2")
371-
assert (
372-
str(err.value)
373-
== f"Major version mismatch. Client {CURRENT_VERSION}, controller 1.0.0."
374-
)
375-
376-
377368
def test_incompatible_version(client_library_server_2_0_0):
378369
with pytest.raises(InitializationError) as err:
379370
with patch.object(
@@ -712,7 +703,7 @@ def test_different_version_strings():
712703
Version("54dev0+build8.7ee86bf8")
713704

714705

715-
def test_import_lab_offline(
706+
def test_import_lab_offline_deprecated(
716707
client_library_server_current, mocked_session, tmp_path: Path, test_dir
717708
):
718709
client_library = ClientLibrary(
@@ -721,7 +712,8 @@ def test_import_lab_offline(
721712
topology_file_path = test_dir / "test_data/sample_topology.json"
722713
with open(topology_file_path) as fh:
723714
topology_file = fh.read()
724-
client_library.import_lab(topology_file, "topology-v0_0_4", offline=True)
715+
with pytest.deprecated_call():
716+
client_library.import_lab(topology_file, "topology-v0_0_4", offline=True)
725717

726718

727719
def test_convergence_parametrization(client_library_server_current, mocked_session):

virl2_client/virl2_client.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def __le__(self, other):
114114
def major_differs(self, other: Version) -> bool:
115115
return self.major != other.major
116116

117+
def major_lt(self, other: Version) -> bool:
118+
return self.major < other.major
119+
117120
def minor_differs(self, other: Version) -> bool:
118121
return self.minor != other.minor
119122

@@ -174,6 +177,12 @@ class ClientLibrary:
174177
Version("2.2.1"),
175178
Version("2.2.2"),
176179
Version("2.2.3"),
180+
Version("2.3.0"),
181+
Version("2.3.1"),
182+
Version("2.4.0"),
183+
Version("2.4.1"),
184+
Version("2.5.0"),
185+
Version("2.5.1"),
177186
]
178187
_URL_TEMPLATES = {
179188
"auth_test": "authok",
@@ -427,14 +436,12 @@ def check_controller_version(self) -> Version | None:
427436
f"List of versions marked explicitly as incompatible: "
428437
f"{self.INCOMPATIBLE_CONTROLLER_VERSIONS}."
429438
)
430-
if self.VERSION.major_differs(controller_version_obj):
439+
if self.VERSION.major_lt(controller_version_obj):
431440
raise InitializationError(
432441
f"Major version mismatch. Client {self.VERSION}, "
433442
f"controller {controller_version_obj}."
434443
)
435-
if self.VERSION.minor_differs(controller_version_obj) and self.VERSION.minor_lt(
436-
controller_version_obj
437-
):
444+
if self.VERSION.minor_lt(controller_version_obj):
438445
_LOGGER.warning(
439446
f"Please ensure the client version is compatible with the controller "
440447
f"version. Client {self.VERSION}, controller {controller_version_obj}."

0 commit comments

Comments
 (0)