mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
rename IntegrationPluginBase to InvenTreePlugin
This commit is contained in:
parent
01e8b5dce3
commit
1571b99ed2
@ -257,9 +257,9 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
plugin = kwargs.get('plugin', None)
|
plugin = kwargs.get('plugin', None)
|
||||||
|
|
||||||
if plugin is not None:
|
if plugin is not None:
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
|
|
||||||
if issubclass(plugin.__class__, IntegrationPluginBase):
|
if issubclass(plugin.__class__, InvenTreePlugin):
|
||||||
plugin = plugin.plugin_config()
|
plugin = plugin.plugin_config()
|
||||||
|
|
||||||
filters['plugin'] = plugin
|
filters['plugin'] = plugin
|
||||||
|
@ -3,13 +3,13 @@ Utility file to enable simper imports
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from .registry import registry
|
from .registry import registry
|
||||||
from .plugin import IntegrationPluginBase
|
from .plugin import InvenTreePlugin
|
||||||
from .helpers import MixinNotImplementedError, MixinImplementationError
|
from .helpers import MixinNotImplementedError, MixinImplementationError
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'registry',
|
'registry',
|
||||||
|
|
||||||
'IntegrationPluginBase',
|
'InvenTreePlugin',
|
||||||
'MixinNotImplementedError',
|
'MixinNotImplementedError',
|
||||||
'MixinImplementationError',
|
'MixinImplementationError',
|
||||||
]
|
]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import ActionMixin
|
from plugin.mixins import ActionMixin
|
||||||
|
|
||||||
|
|
||||||
@ -11,11 +11,11 @@ class ActionMixinTests(TestCase):
|
|||||||
ACTION_RETURN = 'a action was performed'
|
ACTION_RETURN = 'a action was performed'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class SimplePlugin(ActionMixin, IntegrationPluginBase):
|
class SimplePlugin(ActionMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.plugin = SimplePlugin('user')
|
self.plugin = SimplePlugin('user')
|
||||||
|
|
||||||
class TestActionPlugin(ActionMixin, IntegrationPluginBase):
|
class TestActionPlugin(ActionMixin, InvenTreePlugin):
|
||||||
"""a action plugin"""
|
"""a action plugin"""
|
||||||
ACTION_NAME = 'abc123'
|
ACTION_NAME = 'abc123'
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class ActionMixinTests(TestCase):
|
|||||||
|
|
||||||
self.action_plugin = TestActionPlugin('user')
|
self.action_plugin = TestActionPlugin('user')
|
||||||
|
|
||||||
class NameActionPlugin(ActionMixin, IntegrationPluginBase):
|
class NameActionPlugin(ActionMixin, InvenTreePlugin):
|
||||||
PLUGIN_NAME = 'Aplugin'
|
PLUGIN_NAME = 'Aplugin'
|
||||||
|
|
||||||
self.action_name = NameActionPlugin('user')
|
self.action_name = NameActionPlugin('user')
|
||||||
|
@ -5,7 +5,7 @@ from django.conf import settings
|
|||||||
from django.urls import include, re_path
|
from django.urls import include, re_path
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, APICallMixin
|
from plugin.mixins import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, APICallMixin
|
||||||
from plugin.urls import PLUGIN_BASE
|
from plugin.urls import PLUGIN_BASE
|
||||||
|
|
||||||
@ -26,11 +26,11 @@ class SettingsMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
TEST_SETTINGS = {'SETTING1': {'default': '123', }}
|
TEST_SETTINGS = {'SETTING1': {'default': '123', }}
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class SettingsCls(SettingsMixin, IntegrationPluginBase):
|
class SettingsCls(SettingsMixin, InvenTreePlugin):
|
||||||
SETTINGS = self.TEST_SETTINGS
|
SETTINGS = self.TEST_SETTINGS
|
||||||
self.mixin = SettingsCls()
|
self.mixin = SettingsCls()
|
||||||
|
|
||||||
class NoSettingsCls(SettingsMixin, IntegrationPluginBase):
|
class NoSettingsCls(SettingsMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.mixin_nothing = NoSettingsCls()
|
self.mixin_nothing = NoSettingsCls()
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
MIXIN_ENABLE_CHECK = 'has_urls'
|
MIXIN_ENABLE_CHECK = 'has_urls'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class UrlsCls(UrlsMixin, IntegrationPluginBase):
|
class UrlsCls(UrlsMixin, InvenTreePlugin):
|
||||||
def test():
|
def test():
|
||||||
return 'ccc'
|
return 'ccc'
|
||||||
URLS = [re_path('testpath', test, name='test'), ]
|
URLS = [re_path('testpath', test, name='test'), ]
|
||||||
self.mixin = UrlsCls()
|
self.mixin = UrlsCls()
|
||||||
|
|
||||||
class NoUrlsCls(UrlsMixin, IntegrationPluginBase):
|
class NoUrlsCls(UrlsMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.mixin_nothing = NoUrlsCls()
|
self.mixin_nothing = NoUrlsCls()
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class AppMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
MIXIN_ENABLE_CHECK = 'has_app'
|
MIXIN_ENABLE_CHECK = 'has_app'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class TestCls(AppMixin, IntegrationPluginBase):
|
class TestCls(AppMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.mixin = TestCls()
|
self.mixin = TestCls()
|
||||||
|
|
||||||
@ -115,14 +115,14 @@ class NavigationMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
MIXIN_ENABLE_CHECK = 'has_naviation'
|
MIXIN_ENABLE_CHECK = 'has_naviation'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class NavigationCls(NavigationMixin, IntegrationPluginBase):
|
class NavigationCls(NavigationMixin, InvenTreePlugin):
|
||||||
NAVIGATION = [
|
NAVIGATION = [
|
||||||
{'name': 'aa', 'link': 'plugin:test:test_view'},
|
{'name': 'aa', 'link': 'plugin:test:test_view'},
|
||||||
]
|
]
|
||||||
NAVIGATION_TAB_NAME = 'abcd1'
|
NAVIGATION_TAB_NAME = 'abcd1'
|
||||||
self.mixin = NavigationCls()
|
self.mixin = NavigationCls()
|
||||||
|
|
||||||
class NothingNavigationCls(NavigationMixin, IntegrationPluginBase):
|
class NothingNavigationCls(NavigationMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.nothing_mixin = NothingNavigationCls()
|
self.nothing_mixin = NothingNavigationCls()
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class NavigationMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
self.assertEqual(self.mixin.navigation, [{'name': 'aa', 'link': 'plugin:test:test_view'}, ])
|
self.assertEqual(self.mixin.navigation, [{'name': 'aa', 'link': 'plugin:test:test_view'}, ])
|
||||||
# check wrong links fails
|
# check wrong links fails
|
||||||
with self.assertRaises(NotImplementedError):
|
with self.assertRaises(NotImplementedError):
|
||||||
class NavigationCls(NavigationMixin, IntegrationPluginBase):
|
class NavigationCls(NavigationMixin, InvenTreePlugin):
|
||||||
NAVIGATION = ['aa', 'aa']
|
NAVIGATION = ['aa', 'aa']
|
||||||
NavigationCls()
|
NavigationCls()
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
MIXIN_ENABLE_CHECK = 'has_api_call'
|
MIXIN_ENABLE_CHECK = 'has_api_call'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class MixinCls(APICallMixin, SettingsMixin, IntegrationPluginBase):
|
class MixinCls(APICallMixin, SettingsMixin, InvenTreePlugin):
|
||||||
PLUGIN_NAME = "Sample API Caller"
|
PLUGIN_NAME = "Sample API Caller"
|
||||||
|
|
||||||
SETTINGS = {
|
SETTINGS = {
|
||||||
@ -170,11 +170,11 @@ class APICallMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
return self.api_call('api/users/2')
|
return self.api_call('api/users/2')
|
||||||
self.mixin = MixinCls()
|
self.mixin = MixinCls()
|
||||||
|
|
||||||
class WrongCLS(APICallMixin, IntegrationPluginBase):
|
class WrongCLS(APICallMixin, InvenTreePlugin):
|
||||||
pass
|
pass
|
||||||
self.mixin_wrong = WrongCLS()
|
self.mixin_wrong = WrongCLS()
|
||||||
|
|
||||||
class WrongCLS2(APICallMixin, IntegrationPluginBase):
|
class WrongCLS2(APICallMixin, InvenTreePlugin):
|
||||||
API_URL_SETTING = 'test'
|
API_URL_SETTING = 'test'
|
||||||
self.mixin_wrong2 = WrongCLS2()
|
self.mixin_wrong2 = WrongCLS2()
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""sample implementation for ActionMixin"""
|
"""sample implementation for ActionMixin"""
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import ActionMixin
|
from plugin.mixins import ActionMixin
|
||||||
|
|
||||||
|
|
||||||
class SimpleActionPlugin(ActionMixin, IntegrationPluginBase):
|
class SimpleActionPlugin(ActionMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
An EXTREMELY simple action plugin which demonstrates
|
An EXTREMELY simple action plugin which demonstrates
|
||||||
the capability of the ActionMixin class
|
the capability of the ActionMixin class
|
||||||
|
@ -13,7 +13,7 @@ references model objects actually exist in the database.
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import BarcodeMixin
|
from plugin.mixins import BarcodeMixin
|
||||||
|
|
||||||
from stock.models import StockItem, StockLocation
|
from stock.models import StockItem, StockLocation
|
||||||
@ -22,7 +22,7 @@ from part.models import Part
|
|||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeBarcodePlugin(BarcodeMixin, IntegrationPluginBase):
|
class InvenTreeBarcodePlugin(BarcodeMixin, InvenTreePlugin):
|
||||||
|
|
||||||
PLUGIN_NAME = "InvenTreeBarcode"
|
PLUGIN_NAME = "InvenTreeBarcode"
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from allauth.account.models import EmailAddress
|
from allauth.account.models import EmailAddress
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import BulkNotificationMethod, SettingsMixin
|
from plugin.mixins import BulkNotificationMethod, SettingsMixin
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class PlgMixin:
|
|||||||
return CoreNotificationsPlugin
|
return CoreNotificationsPlugin
|
||||||
|
|
||||||
|
|
||||||
class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase):
|
class CoreNotificationsPlugin(SettingsMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
Core notification methods for InvenTree
|
Core notification methods for InvenTree
|
||||||
"""
|
"""
|
||||||
|
@ -11,7 +11,7 @@ from django.contrib.auth.models import User
|
|||||||
|
|
||||||
import common.models
|
import common.models
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase, registry
|
from plugin import InvenTreePlugin, registry
|
||||||
|
|
||||||
|
|
||||||
class PluginConfig(models.Model):
|
class PluginConfig(models.Model):
|
||||||
@ -135,7 +135,7 @@ class PluginSetting(common.models.GenericReferencedSettingClass, common.models.B
|
|||||||
|
|
||||||
if plugin:
|
if plugin:
|
||||||
|
|
||||||
if issubclass(plugin.__class__, IntegrationPluginBase):
|
if issubclass(plugin.__class__, InvenTreePlugin):
|
||||||
plugin = plugin.plugin_config()
|
plugin = plugin.plugin_config()
|
||||||
|
|
||||||
kwargs['settings'] = registry.mixins_settings.get(plugin.key, {})
|
kwargs['settings'] = registry.mixins_settings.get(plugin.key, {})
|
||||||
|
@ -142,11 +142,11 @@ class MixinBase:
|
|||||||
return mixins
|
return mixins
|
||||||
|
|
||||||
|
|
||||||
class IntegrationPluginBase(MixinBase, InvenTreePluginBase):
|
class InvenTreePlugin(MixinBase, InvenTreePluginBase):
|
||||||
"""
|
"""
|
||||||
The IntegrationPluginBase class is used to integrate with 3rd party software
|
The InvenTreePlugin class is used to integrate with 3rd party software
|
||||||
|
|
||||||
DO NOT USE THIS DIRECTLY, USE plugin.IntegrationPluginBase
|
DO NOT USE THIS DIRECTLY, USE plugin.InvenTreePlugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
AUTHOR = None
|
AUTHOR = None
|
||||||
|
@ -25,7 +25,7 @@ from django.utils.text import slugify
|
|||||||
from maintenance_mode.core import maintenance_mode_on
|
from maintenance_mode.core import maintenance_mode_on
|
||||||
from maintenance_mode.core import get_maintenance_mode, set_maintenance_mode
|
from maintenance_mode.core import get_maintenance_mode, set_maintenance_mode
|
||||||
|
|
||||||
from .plugin import IntegrationPluginBase
|
from .plugin import InvenTreePlugin
|
||||||
from .helpers import handle_error, log_error, get_plugins, IntegrationPluginError
|
from .helpers import handle_error, log_error, get_plugins, IntegrationPluginError
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class PluginsRegistry:
|
|||||||
|
|
||||||
# Collect plugins from paths
|
# Collect plugins from paths
|
||||||
for plugin in settings.PLUGIN_DIRS:
|
for plugin in settings.PLUGIN_DIRS:
|
||||||
modules = get_plugins(importlib.import_module(plugin), IntegrationPluginBase)
|
modules = get_plugins(importlib.import_module(plugin), InvenTreePlugin)
|
||||||
if modules:
|
if modules:
|
||||||
[self.plugin_modules.append(item) for item in modules]
|
[self.plugin_modules.append(item) for item in modules]
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
Sample plugin which responds to events
|
Sample plugin which responds to events
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import EventMixin
|
from plugin.mixins import EventMixin
|
||||||
|
|
||||||
|
|
||||||
class EventPluginSample(EventMixin, IntegrationPluginBase):
|
class EventPluginSample(EventMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
A sample plugin which provides supports for triggered events
|
A sample plugin which provides supports for triggered events
|
||||||
"""
|
"""
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""sample implementation for IntegrationPlugin"""
|
"""sample implementation for IntegrationPlugin"""
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import UrlsMixin
|
from plugin.mixins import UrlsMixin
|
||||||
|
|
||||||
|
|
||||||
class NoIntegrationPlugin(IntegrationPluginBase):
|
class NoIntegrationPlugin(InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
An basic integration plugin
|
An basic integration plugin
|
||||||
"""
|
"""
|
||||||
@ -11,7 +11,7 @@ class NoIntegrationPlugin(IntegrationPluginBase):
|
|||||||
PLUGIN_NAME = "NoIntegrationPlugin"
|
PLUGIN_NAME = "NoIntegrationPlugin"
|
||||||
|
|
||||||
|
|
||||||
class WrongIntegrationPlugin(UrlsMixin, IntegrationPluginBase):
|
class WrongIntegrationPlugin(UrlsMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
An basic integration plugin
|
An basic integration plugin
|
||||||
"""
|
"""
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
Sample plugin for calling an external API
|
Sample plugin for calling an external API
|
||||||
"""
|
"""
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import APICallMixin, SettingsMixin
|
from plugin.mixins import APICallMixin, SettingsMixin
|
||||||
|
|
||||||
|
|
||||||
class SampleApiCallerPlugin(APICallMixin, SettingsMixin, IntegrationPluginBase):
|
class SampleApiCallerPlugin(APICallMixin, SettingsMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
A small api call sample
|
A small api call sample
|
||||||
"""
|
"""
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""sample of a broken python file that will be ignored on import"""
|
"""sample of a broken python file that will be ignored on import"""
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
|
|
||||||
|
|
||||||
class BrokenFileIntegrationPlugin(IntegrationPluginBase):
|
class BrokenFileIntegrationPlugin(InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
An very broken integration plugin
|
An very broken integration plugin
|
||||||
"""
|
"""
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""sample of a broken integration plugin"""
|
"""sample of a broken integration plugin"""
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
|
|
||||||
|
|
||||||
class BrokenIntegrationPlugin(IntegrationPluginBase):
|
class BrokenIntegrationPlugin(InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
An very broken integration plugin
|
An very broken integration plugin
|
||||||
"""
|
"""
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
Sample plugin which renders custom panels on certain pages
|
Sample plugin which renders custom panels on certain pages
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import PanelMixin, SettingsMixin
|
from plugin.mixins import PanelMixin, SettingsMixin
|
||||||
|
|
||||||
from part.views import PartDetail
|
from part.views import PartDetail
|
||||||
from stock.views import StockLocationDetail
|
from stock.views import StockLocationDetail
|
||||||
|
|
||||||
|
|
||||||
class CustomPanelSample(PanelMixin, SettingsMixin, IntegrationPluginBase):
|
class CustomPanelSample(PanelMixin, SettingsMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
A sample plugin which renders some custom panels.
|
A sample plugin which renders some custom panels.
|
||||||
"""
|
"""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Sample implementations for IntegrationPlugin
|
Sample implementations for IntegrationPlugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin
|
from plugin.mixins import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
@ -10,7 +10,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.urls import include, re_path
|
from django.urls import include, re_path
|
||||||
|
|
||||||
|
|
||||||
class SampleIntegrationPlugin(AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase):
|
class SampleIntegrationPlugin(AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
A full integration plugin example
|
A full integration plugin example
|
||||||
"""
|
"""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Sample plugin which supports task scheduling
|
Sample plugin which supports task scheduling
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from plugin import IntegrationPluginBase
|
from plugin import InvenTreePlugin
|
||||||
from plugin.mixins import ScheduleMixin, SettingsMixin
|
from plugin.mixins import ScheduleMixin, SettingsMixin
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ def print_world():
|
|||||||
print("World") # pragma: no cover
|
print("World") # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, IntegrationPluginBase):
|
class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, InvenTreePlugin):
|
||||||
"""
|
"""
|
||||||
A sample plugin which provides support for scheduled tasks
|
A sample plugin which provides support for scheduled tasks
|
||||||
"""
|
"""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from plugin import registry, IntegrationPluginBase
|
from plugin import registry, InvenTreePlugin
|
||||||
from plugin.helpers import MixinImplementationError
|
from plugin.helpers import MixinImplementationError
|
||||||
from plugin.registry import call_function
|
from plugin.registry import call_function
|
||||||
from plugin.mixins import ScheduleMixin
|
from plugin.mixins import ScheduleMixin
|
||||||
@ -53,7 +53,7 @@ class ScheduledTaskPluginTests(TestCase):
|
|||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
"""Check that all MixinImplementationErrors raise"""
|
"""Check that all MixinImplementationErrors raise"""
|
||||||
class Base(ScheduleMixin, IntegrationPluginBase):
|
class Base(ScheduleMixin, InvenTreePlugin):
|
||||||
PLUGIN_NAME = 'APlugin'
|
PLUGIN_NAME = 'APlugin'
|
||||||
|
|
||||||
class NoSchedules(Base):
|
class NoSchedules(Base):
|
||||||
|
@ -9,8 +9,8 @@ from django.test import TestCase
|
|||||||
from plugin.samples.integration.sample import SampleIntegrationPlugin
|
from plugin.samples.integration.sample import SampleIntegrationPlugin
|
||||||
from plugin.samples.integration.another_sample import WrongIntegrationPlugin, NoIntegrationPlugin
|
from plugin.samples.integration.another_sample import WrongIntegrationPlugin, NoIntegrationPlugin
|
||||||
import plugin.templatetags.plugin_extras as plugin_tags
|
import plugin.templatetags.plugin_extras as plugin_tags
|
||||||
from plugin import registry, IntegrationPluginBase
|
from plugin import registry, InvenTreePlugin
|
||||||
from plugin.plugin import IntegrationPluginBase
|
from plugin.plugin import InvenTreePlugin
|
||||||
|
|
||||||
|
|
||||||
class PluginTagTests(TestCase):
|
class PluginTagTests(TestCase):
|
||||||
@ -58,24 +58,24 @@ class PluginTagTests(TestCase):
|
|||||||
self.assertEqual(plugin_tags.plugin_errors(), registry.errors)
|
self.assertEqual(plugin_tags.plugin_errors(), registry.errors)
|
||||||
|
|
||||||
|
|
||||||
class IntegrationPluginBaseTests(TestCase):
|
class InvenTreePluginTests(TestCase):
|
||||||
""" Tests for IntegrationPluginBase """
|
""" Tests for InvenTreePlugin """
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.plugin = IntegrationPluginBase()
|
self.plugin = InvenTreePlugin()
|
||||||
|
|
||||||
class NamedPlugin(IntegrationPluginBase):
|
class NamedPlugin(InvenTreePlugin):
|
||||||
"""a named plugin"""
|
"""a named plugin"""
|
||||||
PLUGIN_NAME = 'abc123'
|
PLUGIN_NAME = 'abc123'
|
||||||
|
|
||||||
self.named_plugin = NamedPlugin()
|
self.named_plugin = NamedPlugin()
|
||||||
|
|
||||||
class SimpeIntegrationPluginBase(IntegrationPluginBase):
|
class SimpleInvenTreePlugin(InvenTreePlugin):
|
||||||
PLUGIN_NAME = 'SimplePlugin'
|
PLUGIN_NAME = 'SimplePlugin'
|
||||||
|
|
||||||
self.plugin_simple = SimpeIntegrationPluginBase()
|
self.plugin_simple = SimpleInvenTreePlugin()
|
||||||
|
|
||||||
class NameIntegrationPluginBase(IntegrationPluginBase):
|
class NameInvenTreePlugin(InvenTreePlugin):
|
||||||
PLUGIN_NAME = 'Aplugin'
|
PLUGIN_NAME = 'Aplugin'
|
||||||
PLUGIN_SLUG = 'a'
|
PLUGIN_SLUG = 'a'
|
||||||
PLUGIN_TITLE = 'a titel'
|
PLUGIN_TITLE = 'a titel'
|
||||||
@ -86,7 +86,7 @@ class IntegrationPluginBaseTests(TestCase):
|
|||||||
WEBSITE = 'http://aa.bb/cc'
|
WEBSITE = 'http://aa.bb/cc'
|
||||||
LICENSE = 'MIT'
|
LICENSE = 'MIT'
|
||||||
|
|
||||||
self.plugin_name = NameIntegrationPluginBase()
|
self.plugin_name = NameInvenTreePlugin()
|
||||||
self.plugin_sample = SampleIntegrationPlugin()
|
self.plugin_sample = SampleIntegrationPlugin()
|
||||||
|
|
||||||
def test_basic_plugin_init(self):
|
def test_basic_plugin_init(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user