Skip to content

Commit e67624f

Browse files
authored
Fixes #13666: Fix behavior for reports without test methods (#13667)
1 parent 27297c7 commit e67624f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

netbox/extras/reports.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ def __init__(self):
106106
'failure': 0,
107107
'log': [],
108108
}
109-
if not test_methods:
110-
raise Exception("A report must contain at least one test method.")
111109
self.test_methods = test_methods
112110

113111
@classproperty

netbox/templates/extras/report.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
{% csrf_token %}
1313
{% render_form form %}
1414
<div class="float-end">
15-
<button type="submit" name="_run" class="btn btn-primary">
15+
<button type="submit" name="_run" class="btn btn-primary"
16+
{% if not report.test_methods|length %}
17+
disabled
18+
{% endif %}
19+
>
1620
{% if report.result %}
1721
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
1822
{% else %}

netbox/templates/extras/report_list.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ <h5 class="card-header" id="module{{ module.pk }}">
6868
</td>
6969
{% else %}
7070
<td class="text-muted">{% trans "Never" %}</td>
71-
<td>{{ ''|placeholder }}</td>
71+
{% if report.test_methods|length %}
72+
<td>{{ ''|placeholder }}</td>
73+
{% else %}
74+
<td>
75+
Invalid (no test methods found)
76+
</td>
77+
{% endif %}
7278
{% endif %}
7379
<td>
74-
{% if perms.extras.run_report %}
80+
{% if perms.extras.run_report and report.test_methods|length %}
7581
<div class="float-end noprint">
7682
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
7783
{% csrf_token %}

0 commit comments

Comments
 (0)