From d977aac6a08244d2d298d66da9f2fdfed4d2f3d0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 3 Oct 2021 14:51:37 +0200 Subject: [PATCH] fix test for actions --- .../samples/action/test_samples_action.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/InvenTree/plugins/samples/action/test_samples_action.py b/InvenTree/plugins/samples/action/test_samples_action.py index 865a7c10e9..76fd5f4c2e 100644 --- a/InvenTree/plugins/samples/action/test_samples_action.py +++ b/InvenTree/plugins/samples/action/test_samples_action.py @@ -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, { - "action": 'simple', - "result": True, - "info": { - "user": "testuser", - "hello": "world", - }, - }) + self.assertJSONEqual( + str(respone.content, encoding='utf8'), + { + "action": 'simple', + "result": True, + "info": { + "user": "testuser", + "hello": "world", + }, + } + )