mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Test action error messages
This commit is contained in:
parent
9609d8ae09
commit
aeaf15b374
@ -1,6 +1,7 @@
|
||||
""" Unit tests for action plugins """
|
||||
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from plugin import InvenTreePlugin
|
||||
from plugin.mixins import ActionMixin
|
||||
@ -62,3 +63,32 @@ class ActionMixinTests(TestCase):
|
||||
"result": self.ACTION_RETURN + 'result',
|
||||
"info": self.ACTION_RETURN + 'info',
|
||||
})
|
||||
|
||||
|
||||
class APITests(TestCase):
|
||||
""" Tests for action api """
|
||||
|
||||
def setUp(self):
|
||||
# Create a user for auth
|
||||
user = get_user_model()
|
||||
self.test_user = user.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||
self.client.login(username='testuser', password='password')
|
||||
|
||||
def test_post_errors(self):
|
||||
"""Check the possible errors with post"""
|
||||
|
||||
# Test empty request
|
||||
response = self.client.post('/api/action/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(
|
||||
response.data,
|
||||
{'error': 'No action specified'}
|
||||
)
|
||||
|
||||
# Test non-exsisting action
|
||||
response = self.client.post('/api/action/', data={'action': "nonexsisting"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(
|
||||
response.data,
|
||||
{'error': 'No matching action found', 'action': 'nonexsisting'}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user