-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #13666: Fix behavior for reports without test methods #13667
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A much simpler fix would be to simply remove the exception (below) and perhaps add a warning to the UI when viewing a report with no test methods. (It might also make sense to disable the "run" action.)
netbox/netbox/extras/reports.py
Lines 109 to 110 in 0ce2b1b
if not test_methods: | |
raise Exception("A report must contain at least one test method.") |
Yes I will do that. I hesitated to remove the exception, as I thought it was maybe important (And just not documented, why missing test methods should be an error instead of an warning - thus this more complex solution) |
I would change the text to something like "Invalid (no test methods found)" and remove the alert styling (it's not intended for table cells). But otherwise yes I think this is great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JCWasmx86!
Fixes: #13666
If you upload a report file without any test methods, the entire GUI for the reports page fails. This fixes the error by splitting up the
report_modules
into valid and empty ones. The validreport_module
s are rendered as before, the empty ones are listed with the possibility to delete them. (Before you had to drop into the CLI to delete them)The list of reports without test methods are at the top of the page to increase the visibility of them, but you could consider moving them into the normal list of reports, but show an error/warning there - similar to e.g. "Failed to load foo.py"
Additionally there is a second commit (But can be either dropped/moved to new PR as it changes the scope of the issue a little bit). It fixes the API by filtering out those reports
Note: I wasn't able to run black, as
black --config pyproject.toml netbox/
wants to reformat everything, butpycodestyle --ignore=W504,E501 netbox/
shows no warnings)