mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
activate plugins before testing
This commit is contained in:
parent
c612cfcfba
commit
938f8bab2d
@ -22,6 +22,7 @@ import InvenTree.version
|
||||
from common.models import InvenTreeSetting
|
||||
from .settings import MEDIA_URL, STATIC_URL
|
||||
from common.settings import currency_code_default
|
||||
from plugin.models import PluginConfig
|
||||
|
||||
from djmoney.money import Money
|
||||
|
||||
@ -711,3 +712,12 @@ def inheritors(cls):
|
||||
subcls.add(child)
|
||||
work.append(child)
|
||||
return subcls
|
||||
|
||||
|
||||
def setup_plugin(plg_key, plg_name):
|
||||
"""
|
||||
Enables plugins by reference
|
||||
"""
|
||||
plg_setting, _ = PluginConfig.objects.get_or_create(key=plg_key, name=plg_name)
|
||||
plg_setting.active = True
|
||||
plg_setting.save()
|
||||
|
@ -3,6 +3,10 @@
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from InvenTree.helpers import setup_plugin
|
||||
|
||||
from plugin.samples.integration.sample import SampleIntegrationPlugin
|
||||
|
||||
|
||||
class SampleIntegrationPluginTests(TestCase):
|
||||
""" Tests for SampleIntegrationPlugin """
|
||||
@ -13,6 +17,7 @@ class SampleIntegrationPluginTests(TestCase):
|
||||
user.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||
|
||||
self.client.login(username='testuser', password='password')
|
||||
setup_plugin(SampleIntegrationPlugin.PLUGIN_SLUG, SampleIntegrationPlugin.PLUGIN_NAME)
|
||||
|
||||
def test_view(self):
|
||||
"""check the function of the custom sample plugin """
|
||||
|
@ -7,7 +7,9 @@ from django.contrib.auth import get_user_model
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from InvenTree.helpers import setup_plugin
|
||||
from plugin.integration import AppMixin, IntegrationPluginBase, SettingsMixin, UrlsMixin, NavigationMixin
|
||||
from plugin.samples.integration.sample import SampleIntegrationPlugin
|
||||
|
||||
|
||||
class BaseMixinDefinition:
|
||||
@ -110,6 +112,8 @@ class AppMixinTest(BaseMixinDefinition, TestCase):
|
||||
pass
|
||||
self.mixin = TestCls()
|
||||
|
||||
setup_plugin(SampleIntegrationPlugin.PLUGIN_SLUG, SampleIntegrationPlugin.PLUGIN_NAME)
|
||||
|
||||
def test_function(self):
|
||||
# test that this plugin is in settings
|
||||
self.assertIn('plugin.samples.integration', settings.INSTALLED_APPS)
|
||||
|
Loading…
Reference in New Issue
Block a user