Using APIViewTestCases and ViewTestCases in plugins #10279
Labels
complexity: medium
Requires a substantial but not unusual amount of effort to implement
needs milestone
Awaiting prioritization for inclusion with a future NetBox release
netbox
status: backlog
Awaiting selection for work
topic: plugins
Relates to the plugins framework
type: feature
Introduction of new functionality to the application
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.py
Use 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.
The text was updated successfully, but these errors were encountered: