Open miaow2 opened 2 years ago
As it's been a while - I wholeheartedly support this issue.
I've been (semi-legally :-)) using inherited versions of the classes in question since the beginning and found lots of errors that way - actually a long time ago I raised this a while ago, but lost track of it.
NetBox version
v3.3.0
Feature type
Change to existing functionality
Proposed functionality
Hi, NetBox team! I am writing a plugin for NetBox and want to use APIViewTestCases and ViewTestCases in tests. But they don't work because test cases don't know that plugins namespaces are extended by
plugins:
andplugins-api:
. GraphQLTestCase does not work because function dynamic_import (fromutilities/utils.py
) can't import plugins graphql types.I've made several changes and test cases started working in plugins. NetBox core tests also working. Check changes below.
In API and views test cases checks if
app_label
is insettings.PLUGINS
utilities/testing/api.py
utilities/testing/api.py
In GraphQLTestCase I'm using
import_object
(fromextras/plugins/utils.py
) instead ofdynamic_import
for plugins. utilities/testing/api.pyUse case
It would be great to use NetBox abstractions in plugin testing, it really simplifies the work. I can create a pull request if this solution is right for you. If not, feel free to close this issue. Early I've opened discussion.
Database changes
There are no database changes.
External dependencies
There are no external dependencies.