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): 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(
"action": 'simple', str(respone.content, encoding='utf8'),
"result": True, {
"info": { "action": 'simple',
"user": "testuser", "result": True,
"hello": "world", "info": {
}, "user": "testuser",
}) "hello": "world",
},
}
)