mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix test for actions
This commit is contained in:
parent
fadf4d5ca8
commit
d977aac6a0
@ -12,11 +12,10 @@ class SimpleActionPluginTests(TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Create a user for auth
|
# Create a user for auth
|
||||||
user = get_user_model()
|
user = get_user_model()
|
||||||
user.objects.create_user('testuser', 'test@testing.com', 'password')
|
self.test_user = user.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||||
|
|
||||||
self.client.login(username='testuser', password='password')
|
self.client.login(username='testuser', password='password')
|
||||||
|
self.plugin = SimpleActionPlugin(user=self.test_user)
|
||||||
self.plugin = SimpleActionPlugin()
|
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self):
|
||||||
"""check plugn names """
|
"""check plugn names """
|
||||||
@ -26,13 +25,16 @@ class SimpleActionPluginTests(TestCase):
|
|||||||
def test_function(self):
|
def test_function(self):
|
||||||
"""check if functions work """
|
"""check if functions work """
|
||||||
# test functions
|
# test functions
|
||||||
respone = self.client.get('/action/sample/')
|
respone = self.client.post('/api/action/', data={'action': "simple", 'data': {'foo': "bar",}})
|
||||||
self.assertEqual(respone.status_code, 200)
|
self.assertEqual(respone.status_code, 200)
|
||||||
self.assertEqual(respone.content, {
|
self.assertJSONEqual(
|
||||||
|
str(respone.content, encoding='utf8'),
|
||||||
|
{
|
||||||
"action": 'simple',
|
"action": 'simple',
|
||||||
"result": True,
|
"result": True,
|
||||||
"info": {
|
"info": {
|
||||||
"user": "testuser",
|
"user": "testuser",
|
||||||
"hello": "world",
|
"hello": "world",
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user