mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
test sample code
This commit is contained in:
parent
2b2238049a
commit
cfef5d63b3
38
InvenTree/plugins/samples/action/test_samples.py
Normal file
38
InvenTree/plugins/samples/action/test_samples.py
Normal 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",
|
||||
},
|
||||
})
|
21
InvenTree/plugins/samples/integration/test_samples.py
Normal file
21
InvenTree/plugins/samples/integration/test_samples.py
Normal 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')
|
Loading…
Reference in New Issue
Block a user