2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 03:55:41 +00:00
Files
InvenTree/InvenTree/plugin/samples/integration/test_simpleactionplugin.py
2023-05-13 22:59:09 +10:00

37 lines
1.1 KiB
Python

"""Unit tests for action plugins."""
from InvenTree.api_tester import InvenTreeTestCase
from plugin.samples.integration.simpleactionplugin import SimpleActionPlugin
class SimpleActionPluginTests(InvenTreeTestCase):
"""Tests for SampleIntegrationPlugin."""
def setUp(self):
"""Setup for tests."""
super().setUp()
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
response = self.client.post('/api/action/', data={'action': "simple", 'data': {'foo': "bar", }})
self.assertEqual(response.status_code, 200)
self.assertJSONEqual(
str(response.content, encoding='utf8'),
{
"action": 'simple',
"result": True,
"info": {
"user": self.username,
"hello": "world",
},
}
)