fix test for actions

This commit is contained in:
Matthias 2021-10-03 14:51:37 +02:00
parent fadf4d5ca8
commit d977aac6a0
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -12,11 +12,10 @@ class SimpleActionPluginTests(TestCase):
def setUp(self):
# Create a user for auth
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.plugin = SimpleActionPlugin()
self.plugin = SimpleActionPlugin(user=self.test_user)
def test_name(self):
"""check plugn names """
@ -26,13 +25,16 @@ class SimpleActionPluginTests(TestCase):
def test_function(self):
"""check if functions work """
# 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.content, {
self.assertJSONEqual(
str(respone.content, encoding='utf8'),
{
"action": 'simple',
"result": True,
"info": {
"user": "testuser",
"hello": "world",
},
})
}
)