Skip to content

Commit ceaabe7

Browse files
committed
Remove old version workarounds
1 parent 6d40312 commit ceaabe7

2 files changed

Lines changed: 5 additions & 39 deletions

File tree

netbox_kea/views.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import inspect
21
import logging
32
from abc import ABCMeta
43
from typing import Any, Generic, Literal, TypeVar
@@ -30,9 +29,6 @@
3029

3130
T = TypeVar("T", bound=BaseTable)
3231

33-
# See BaseServerLeasesView.get_table.
34-
_TABLE_USER_ARG = "user" in inspect.signature(BaseTable).parameters
35-
3632

3733
@register_model_view(Server)
3834
class ServerView(generic.ObjectView):
@@ -174,15 +170,7 @@ class BaseServerLeasesView(generic.ObjectView, Generic[T]):
174170
table: type[T]
175171

176172
def get_table(self, data: list[dict[str, Any]], request: HttpRequest) -> T:
177-
table_kwargs = {}
178-
if _TABLE_USER_ARG:
179-
# The user arg is used by NetBox <4.3 to configure the table.
180-
# It is available in 4.3, 4.4 and certain 4.5 versions
181-
# but is not used. Configuring the table in these versions
182-
# is done by .configure.
183-
table_kwargs["user"] = request.user
184-
185-
table = self.table(data, **table_kwargs)
173+
table = self.table(data)
186174
table.configure(request)
187175
return table
188176

tests/test_ui.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -481,22 +481,6 @@ def expect_form_error_search(page: Page, b: bool) -> None:
481481
expect(page.locator("#id_q + div.form-text.text-danger")).to_have_count(int(b))
482482

483483

484-
def _version_ge_43(page: Page) -> bool:
485-
"""
486-
Return True if the version is >= 4.3.
487-
"""
488-
489-
old_version_strings = (
490-
"(v4.0.11)",
491-
'<li class="list-inline-item">NetBox Community v4.1.11</li>',
492-
"NetBox Community v4.2",
493-
)
494-
495-
content = page.content()
496-
497-
return not any(s in content for s in old_version_strings)
498-
499-
500484
def configure_table(page: Page, *selected_coumns: str) -> None:
501485
page.get_by_role("button", name=re.compile("Configure Table")).click()
502486

@@ -874,10 +858,7 @@ def search() -> None:
874858
"expires_in",
875859
"iaid",
876860
)
877-
# NetBox v4.3 removes the query when saving the table config.
878-
# See table tableConfig.ts in https://github.com/netbox-community/netbox/pull/19284.
879-
if _version_ge_43(page):
880-
search()
861+
search()
881862

882863
def check():
883864
cltt = datetime.fromtimestamp(lease["cltt"], timezone.utc)
@@ -913,8 +894,7 @@ def check():
913894
"expires_in",
914895
"client_id",
915896
)
916-
if _version_ge_43(page):
917-
search()
897+
search()
918898

919899
def check():
920900
cltt = datetime.fromtimestamp(lease["cltt"], timezone.utc)
@@ -1003,8 +983,7 @@ def search() -> None:
1003983

1004984
search()
1005985
configure_table(page, "ip_address", "hostname", "subnet_id")
1006-
if _version_ge_43(page):
1007-
search()
986+
search()
1008987

1009988
page.get_by_role("button", name="Export").click()
1010989
with page.expect_download() as dl:
@@ -1570,8 +1549,7 @@ def search() -> None:
15701549
"hostname",
15711550
"hw_address",
15721551
)
1573-
if _version_ge_43(page):
1574-
search()
1552+
search()
15751553

15761554
# The last column should not be off the page.
15771555
expect(page.locator("table.object-list > tbody > tr > td").last).to_be_in_viewport()

0 commit comments

Comments
 (0)