diff mbox series

[01/10] REST: Check.user is not read-only

Message ID 20190430060308.10432-2-dja@axtens.net
State Accepted
Headers show
Series Patchwork 2.1.2 review series | expand

Commit Message

Daniel Axtens April 30, 2019, 6:02 a.m. UTC
From: Stephen Finucane <stephen@that.guru>

We only support 'Check' creation - not check updating. As a result,
there's no real reason that the 'Check.user' field should be read-only
and this is causing an issue with Django REST Framework 3.7. Simply
remove the attribute and extend the tests to validate things are working
as expected.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
(cherry picked from commit c9cc59dac70d76971a5342ca53e2b13eb93592de)
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/api/check.py            | 2 +-
 patchwork/tests/api/test_check.py | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Finucane April 30, 2019, 5:49 p.m. UTC | #1
On Tue, 2019-04-30 at 16:02 +1000, Daniel Axtens wrote:
> From: Stephen Finucane <stephen@that.guru>
> 
> We only support 'Check' creation - not check updating. As a result,
> there's no real reason that the 'Check.user' field should be read-only
> and this is causing an issue with Django REST Framework 3.7. Simply
> remove the attribute and extend the tests to validate things are working
> as expected.
> 
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> Reviewed-by: Daniel Axtens <dja@axtens.net>
> Signed-off-by: Daniel Axtens <dja@axtens.net>
> (cherry picked from commit c9cc59dac70d76971a5342ca53e2b13eb93592de)
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Makes sense. Applied.
diff mbox series

Patch

diff --git a/patchwork/api/check.py b/patchwork/api/check.py
index 594ecd4bfeec..d76573a528ec 100644
--- a/patchwork/api/check.py
+++ b/patchwork/api/check.py
@@ -46,7 +46,7 @@  class CheckSerializer(HyperlinkedModelSerializer):
 
     url = CheckHyperlinkedIdentityField('api-check-detail')
     patch = HiddenField(default=CurrentPatchDefault())
-    user = UserSerializer(read_only=True, default=CurrentUserDefault())
+    user = UserSerializer(default=CurrentUserDefault())
 
     def run_validation(self, data):
         for val, label in Check.STATE_CHOICES:
diff --git a/patchwork/tests/api/test_check.py b/patchwork/tests/api/test_check.py
index bc06e86e5bb3..f5a8eca155a9 100644
--- a/patchwork/tests/api/test_check.py
+++ b/patchwork/tests/api/test_check.py
@@ -67,6 +67,7 @@  class TestCheckAPI(APITestCase):
         self.assertEqual(check_obj.target_url, check_json['target_url'])
         self.assertEqual(check_obj.context, check_json['context'])
         self.assertEqual(check_obj.description, check_json['description'])
+        self.assertEqual(check_obj.user.id, check_json['user']['id'])
 
     def test_list(self):
         """Validate we can list checks on a patch."""