From 18630c0e0f08292157a8a900f8bd463ebb6835e8 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 5 Oct 2021 00:40:20 +0200 Subject: [PATCH] more tests for integrationbase --- .../plugins/samples/integration/sample.py | 4 +- InvenTree/plugins/test_integration.py | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/InvenTree/plugins/samples/integration/sample.py b/InvenTree/plugins/samples/integration/sample.py index adfe74d7f6..381d91d1cd 100644 --- a/InvenTree/plugins/samples/integration/sample.py +++ b/InvenTree/plugins/samples/integration/sample.py @@ -1,12 +1,12 @@ """sample implementations for IntegrationPlugin""" -from plugins.integration import SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase +from plugins.integration import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase from django.http import HttpResponse from django.utils.translation import ugettext_lazy as _ from django.conf.urls import url, include -class SampleIntegrationPlugin(SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase): +class SampleIntegrationPlugin(AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase): """ An full integration plugin """ diff --git a/InvenTree/plugins/test_integration.py b/InvenTree/plugins/test_integration.py index 7a36f702ba..86484dd95b 100644 --- a/InvenTree/plugins/test_integration.py +++ b/InvenTree/plugins/test_integration.py @@ -110,3 +110,51 @@ class NavigationMixinTest(BaseMixinDefinition, TestCase): class NavigationCls(NavigationMixin, IntegrationPluginBase): NAVIGATION = ['aa', 'aa'] NavigationCls() + + +class IntegrationPluginBaseTests(TestCase): + """ Tests for IntegrationPluginBase """ + + def setUp(self): + self.plugin = IntegrationPluginBase() + + class SimpeIntegrationPluginBase(IntegrationPluginBase): + PLUGIN_NAME = 'SimplePlugin' + + self.plugin_simple = SimpeIntegrationPluginBase() + + class NameIntegrationPluginBase(IntegrationPluginBase): + PLUGIN_NAME = 'Aplugin' + PLUGIN_SLUG = 'a' + PLUGIN_TITLE = 'a titel' + PUBLISH_DATE = "1111.11.11" + VERSION = '1.2.3a' + + self.plugin_name = NameIntegrationPluginBase() + + def test_action_name(self): + """check the name definition possibilities""" + # plugin_name + self.assertEqual(self.plugin.plugin_name(), '') + self.assertEqual(self.plugin_simple.plugin_name(), 'SimplePlugin') + self.assertEqual(self.plugin_name.plugin_name(), 'Aplugin') + + # slug + self.assertEqual(self.plugin.slug, '') + self.assertEqual(self.plugin_simple.slug, 'simpleplugin') + self.assertEqual(self.plugin_name.slug, 'a') + + # human_name + self.assertEqual(self.plugin.human_name, '') + self.assertEqual(self.plugin_simple.human_name, 'SimplePlugin') + self.assertEqual(self.plugin_name.human_name, 'a titel') + + # pub_date + self.assertEqual(self.plugin.pub_date, 'No date found') + self.assertEqual(self.plugin_simple.pub_date, 'No date found') + self.assertEqual(self.plugin_name.pub_date, "1111.11.11") + + # version + self.assertEqual(self.plugin.version, None) + self.assertEqual(self.plugin_simple.version, None) + self.assertEqual(self.plugin_name.version, '1.2.3a')