own flag to enable plugin testing

This commit is contained in:
Matthias 2021-11-13 01:39:22 +01:00
parent 860c56e4ca
commit 2638ef046d
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
4 changed files with 6 additions and 5 deletions

View File

@ -55,6 +55,7 @@ def get_setting(environment_var, backup_val, default_value=None):
# Determine if we are running in "test" mode e.g. "manage.py test"
TESTING = 'test' in sys.argv
PLUGIN_TESTING = TESTING # used to forece enable everything plugin
# New requirement for django 3.2+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

View File

@ -125,7 +125,7 @@ translated_javascript_urls = [
# Integration plugin urls
interation_urls = []
try:
if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'):
if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_URL'):
for plugin in settings.INTEGRATION_PLUGINS.values():
if plugin.mixin_enabled('urls'):
interation_urls.append(plugin.urlpatterns)

View File

@ -69,7 +69,7 @@ class PluginAppConfig(AppConfig):
plugin_db_setting, _ = PluginConfig.objects.get_or_create(key=plug_key, name=plug_name)
# always activate if testing
if settings.TESTING or plugin_db_setting.active:
if settings.PLUGIN_TESTING or plugin_db_setting.active:
# init package
# now we can be sure that an admin has activated the plugin -> as of Nov 2021 there are not many checks in place
# but we could enhance those to check signatures, run the plugin against a whitelist etc.
@ -100,7 +100,7 @@ class PluginAppConfig(AppConfig):
def activate_integration_settings(self, plugins):
from common.models import InvenTreeSetting
if settings.TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'):
if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SETTING'):
logger.info('Registering IntegrationPlugin settings')
for slug, plugin in plugins:
if plugin.mixin_enabled('settings'):
@ -113,7 +113,7 @@ class PluginAppConfig(AppConfig):
def activate_integration_app(self, plugins):
from common.models import InvenTreeSetting
if settings.TESTING or ((not settings.INTEGRATION_APPS_LOADED) and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')):
if settings.PLUGIN_TESTING or ((not settings.INTEGRATION_APPS_LOADED) and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')):
logger.info('Registering IntegrationPlugin apps')
settings.INTEGRATION_APPS_LOADED = True # ensure this section will not run again
apps_changed = False

View File

@ -39,7 +39,7 @@ def mixin_enabled(plugin, key, *args, **kwargs):
@register.simple_tag()
def navigation_enabled(*args, **kwargs):
"""Return if plugin navigation is enabled"""
if djangosettings.TESTING:
if djangosettings.PLUGIN_TESTING:
return True
return InvenTreeSetting.get_setting('ENABLE_PLUGINS_NAVIGATION')