Skip to content

Commit

Permalink
run tests directly from validity menu
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov committed Jan 19, 2024
1 parent df10ed8 commit 3c7d92c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 80 deletions.
115 changes: 35 additions & 80 deletions validity/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,90 +2,45 @@
from utilities.choices import ButtonColorChoices


def model_add_button(entity):
return PluginMenuButton(
link=f"plugins:validity:{entity}_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
permissions=[f"validity.add_{entity}"],
)


def model_menu_item(entity, title, buttons=()):
buttons = [btn(entity) if callable(btn) else btn for btn in buttons]
return PluginMenuItem(
link=f"plugins:validity:{entity}_list",
link_text=title,
buttons=buttons or [],
permissions=[f"validity.view_{entity}"],
)


run_tests_button = PluginMenuButton(
link="plugins:validity:compliancetest_run",
title="Run",
icon_class="mdi mdi-rocket-launch",
color=ButtonColorChoices.CYAN,
)

validity_menu_items = (
PluginMenuItem(
link="plugins:validity:complianceselector_list",
link_text="Selectors",
buttons=[
PluginMenuButton(
link="plugins:validity:complianceselector_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
PluginMenuItem(
link="plugins:validity:compliancetest_list",
link_text="Tests",
buttons=[
PluginMenuButton(
link="plugins:validity:compliancetest_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
PluginMenuItem(
link="plugins:validity:compliancetestresult_list",
link_text="Test Results",
),
PluginMenuItem(
link="plugins:validity:compliancereport_list",
link_text="Reports",
),
PluginMenuItem(
link="plugins:validity:serializer_list",
link_text="Serializers",
buttons=[
PluginMenuButton(
link="plugins:validity:serializer_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
PluginMenuItem(
link="plugins:validity:nameset_list",
link_text="Name Sets",
buttons=[
PluginMenuButton(
link="plugins:validity:nameset_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
model_menu_item("complianceselector", "Selectors", [model_add_button]),
model_menu_item("compliancetest", "Tests", [run_tests_button, model_add_button]),
model_menu_item("compliancetestresult", "Test Results"),
model_menu_item("compliancereport", "Reports"),
model_menu_item("serializer", "Serializers", [model_add_button]),
model_menu_item("nameset", "Name Sets", [model_add_button]),
)

polling_menu_items = (
PluginMenuItem(
link="plugins:validity:poller_list",
link_text="Pollers",
buttons=[
PluginMenuButton(
link="plugins:validity:poller_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
PluginMenuItem(
link="plugins:validity:command_list",
link_text="Commands",
buttons=[
PluginMenuButton(
link="plugins:validity:command_add",
title="Add",
icon_class="mdi mdi-plus-thick",
color=ButtonColorChoices.GREEN,
),
],
),
model_menu_item("command", "Commands", [model_add_button]),
model_menu_item("poller", "Pollers", [model_add_button]),
)

menu = PluginMenu(
Expand Down
6 changes: 6 additions & 0 deletions validity/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.shortcuts import redirect
from django.urls import include, path
from utilities.urls import get_model_urls

Expand All @@ -10,6 +11,11 @@
path("selectors/delete/", views.ComplianceSelectorBulkDeleteView.as_view(), name="complianceselector_bulk_delete"),
path("selectors/<int:pk>/", include(get_model_urls("validity", "complianceselector"))),
path("tests/", views.ComplianceTestListView.as_view(), name="compliancetest_list"),
path(
"tests/run/",
lambda _: redirect("extras:script", module="validity_scripts", name="RunTests"),
name="compliancetest_run",
),
path("tests/add/", views.ComplianceTestEditView.as_view(), name="compliancetest_add"),
path("tests/delete/", views.ComplianceTestBulkDeleteView.as_view(), name="compliancetest_bulk_delete"),
path("tests/<int:pk>/", include(get_model_urls("validity", "compliancetest"))),
Expand Down

0 comments on commit 3c7d92c

Please sign in to comment.