test sample code

This commit is contained in:
Matthias 2021-09-29 00:24:09 +02:00
parent 2b2238049a
commit cfef5d63b3
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,38 @@
""" Unit tests for action plugins """
from django.test import TestCase
from django.contrib.auth import get_user_model
from plugins.samples.action.simpleactionplugin import SimpleActionPlugin
class ActionPluginTests(TestCase):
""" Tests for SampleIntegrationPlugin """
def setUp(self):
# Create a user for auth
user = get_user_model()
user.objects.create_user('testuser', 'test@testing.com', 'password')
self.client.login(username='testuser', password='password')
self.plugin = SimpleActionPlugin
def test_name(self):
"""check plugn names """
self.assertEqual(self.plugin.plugin_name(), "SimpleActionPlugin")
self.assertEqual(self.plugin.action_name(), "simple")
def test_function(self):
"""check if functions work """
# test functions
respone = self.client.get('/action/sample/')
self.assertEqual(respone.status_code, 200)
self.assertEqual(respone.content, {
"action": 'simple',
"result": True,
"info": {
"user": "testuser",
"hello": "world",
},
})

View File

@ -0,0 +1,21 @@
""" Unit tests for action plugins """
from django.test import TestCase
from django.contrib.auth import get_user_model
class ActionPluginTests(TestCase):
""" Tests for SampleIntegrationPlugin """
def setUp(self):
# Create a user for auth
user = get_user_model()
user.objects.create_user('testuser', 'test@testing.com', 'password')
self.client.login(username='testuser', password='password')
def test_view(self):
"""check the function of the custom sample plugin """
respone = self.client.get('/plugin/SampleIntegrationPlugin/ho/he/')
self.assertEqual(respone.status_code, 200)
self.assertEqual(respone.content, b'Hi there testuser this work')