|
@@ -81,10 +81,10 @@ class ThreadChangeTitleApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(response_json['detail'][0], "You can't edit threads in this category.")
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't edit threads in this category."
|
|
|
|
+ })
|
|
|
|
|
|
def test_change_thread_title_closed_category_no_permission(self):
|
|
def test_change_thread_title_closed_category_no_permission(self):
|
|
"""api test permission to edit thread title in closed category"""
|
|
"""api test permission to edit thread title in closed category"""
|
|
@@ -105,12 +105,11 @@ class ThreadChangeTitleApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't edit threads in it."
|
|
|
|
+ })
|
|
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This category is closed. You can't edit threads in it."
|
|
|
|
- )
|
|
|
|
|
|
|
|
def test_change_thread_title_closed_thread_no_permission(self):
|
|
def test_change_thread_title_closed_thread_no_permission(self):
|
|
"""api test permission to edit closed thread title"""
|
|
"""api test permission to edit closed thread title"""
|
|
@@ -131,12 +130,10 @@ class ThreadChangeTitleApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This thread is closed. You can't edit it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't edit it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_change_thread_title_after_edit_time(self):
|
|
def test_change_thread_title_after_edit_time(self):
|
|
"""api cleans, validates and rejects too short title"""
|
|
"""api cleans, validates and rejects too short title"""
|
|
@@ -155,12 +152,10 @@ class ThreadChangeTitleApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't edit threads that are older than 1 minute."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't edit threads that are older than 1 minute."
|
|
|
|
+ })
|
|
|
|
|
|
def test_change_thread_title_invalid(self):
|
|
def test_change_thread_title_invalid(self):
|
|
"""api cleans, validates and rejects too short title"""
|
|
"""api cleans, validates and rejects too short title"""
|
|
@@ -176,12 +171,9 @@ class ThreadChangeTitleApiTests(ThreadPatchApiTestCase):
|
|
]
|
|
]
|
|
)
|
|
)
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(response.status_code, 400)
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0],
|
|
|
|
- "Thread title should be at least 5 characters long (it has 2)."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': ["Thread title should be at least 5 characters long (it has 2)."]
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
@@ -225,12 +217,10 @@ class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This category is closed. You can't change threads weights in it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't change threads weights in it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_pin_thread_closed_no_permission(self):
|
|
def test_pin_thread_closed_no_permission(self):
|
|
"""api checks if thread is closed"""
|
|
"""api checks if thread is closed"""
|
|
@@ -251,12 +241,10 @@ class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This thread is closed. You can't change its weight."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't change its weight."
|
|
|
|
+ })
|
|
|
|
|
|
def test_unpin_thread(self):
|
|
def test_unpin_thread(self):
|
|
"""api makes it possible to unpin thread"""
|
|
"""api makes it possible to unpin thread"""
|
|
@@ -298,12 +286,10 @@ class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't pin threads globally in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't pin threads globally in this category."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertEqual(thread_json['weight'], 0)
|
|
self.assertEqual(thread_json['weight'], 0)
|
|
@@ -327,12 +313,10 @@ class ThreadPinGloballyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't change globally pinned threads weights in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't change globally pinned threads weights in this category."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertEqual(thread_json['weight'], 2)
|
|
self.assertEqual(thread_json['weight'], 2)
|
|
@@ -400,12 +384,10 @@ class ThreadPinLocallyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't change threads weights in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't change threads weights in this category."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertEqual(thread_json['weight'], 0)
|
|
self.assertEqual(thread_json['weight'], 0)
|
|
@@ -429,12 +411,10 @@ class ThreadPinLocallyApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't change threads weights in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't change threads weights in this category."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertEqual(thread_json['weight'], 1)
|
|
self.assertEqual(thread_json['weight'], 1)
|
|
@@ -639,13 +619,11 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't move threads in this category."
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't move threads in this category."
|
|
|
|
+ })
|
|
|
|
+
|
|
self.override_other_acl({})
|
|
self.override_other_acl({})
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
@@ -671,12 +649,10 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This category is closed. You can't move it's threads."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't move it's threads."
|
|
|
|
+ })
|
|
|
|
|
|
def test_move_closed_thread_no_permission(self):
|
|
def test_move_closed_thread_no_permission(self):
|
|
"""api move closed thread with no permission fails"""
|
|
"""api move closed thread with no permission fails"""
|
|
@@ -698,12 +674,10 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This thread is closed. You can't move it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't move it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_move_thread_no_category_access(self):
|
|
def test_move_thread_no_category_access(self):
|
|
"""api move thread to category with no access fails"""
|
|
"""api move thread to category with no access fails"""
|
|
@@ -719,10 +693,10 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(response_json['detail'][0], 'NOT FOUND')
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 404)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "NOT FOUND"
|
|
|
|
+ })
|
|
|
|
|
|
self.override_other_acl({})
|
|
self.override_other_acl({})
|
|
|
|
|
|
@@ -743,13 +717,10 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0],
|
|
|
|
- 'You don\'t have permission to browse "Category B" contents.'
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': 'You don\'t have permission to browse "Category B" contents.'
|
|
|
|
+ })
|
|
|
|
|
|
self.override_other_acl({})
|
|
self.override_other_acl({})
|
|
|
|
|
|
@@ -770,13 +741,10 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0],
|
|
|
|
- "You don't have permission to start new threads in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You don't have permission to start new threads in this category."
|
|
|
|
+ })
|
|
|
|
|
|
self.override_other_acl({})
|
|
self.override_other_acl({})
|
|
|
|
|
|
@@ -798,11 +766,9 @@ class ThreadMoveApiTests(ThreadPatchApiTestCase):
|
|
]
|
|
]
|
|
)
|
|
)
|
|
self.assertEqual(response.status_code, 400)
|
|
self.assertEqual(response.status_code, 400)
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't move thread to the category it's already in."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': ["You can't move thread to the category it's already in."]
|
|
|
|
+ })
|
|
|
|
|
|
self.override_other_acl({})
|
|
self.override_other_acl({})
|
|
|
|
|
|
@@ -888,12 +854,10 @@ class ThreadCloseApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You don't have permission to close this thread."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You don't have permission to close this thread."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertFalse(thread_json['is_closed'])
|
|
self.assertFalse(thread_json['is_closed'])
|
|
@@ -917,12 +881,10 @@ class ThreadCloseApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You don't have permission to open this thread."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You don't have permission to open this thread."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertTrue(thread_json['is_closed'])
|
|
self.assertTrue(thread_json['is_closed'])
|
|
@@ -993,10 +955,10 @@ class ThreadApproveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(response_json['detail'][0], "This category is closed. You can't approve threads in it.")
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't approve threads in it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_approve_thread_closed_no_permission(self):
|
|
def test_approve_thread_closed_no_permission(self):
|
|
"""api checks permission for approving posts in closed categories"""
|
|
"""api checks permission for approving posts in closed categories"""
|
|
@@ -1026,10 +988,10 @@ class ThreadApproveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(response_json['detail'][0], "This thread is closed. You can't approve it.")
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't approve it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_unapprove_thread(self):
|
|
def test_unapprove_thread(self):
|
|
"""api returns permission error on approval removal"""
|
|
"""api returns permission error on approval removal"""
|
|
@@ -1044,10 +1006,10 @@ class ThreadApproveApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(response_json['detail'][0], "Content approval can't be reversed.")
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "Content approval can't be reversed."
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
@@ -1087,12 +1049,10 @@ class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't hide threads in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't hide threads in this category."
|
|
|
|
+ })
|
|
|
|
|
|
thread_json = self.get_thread_json()
|
|
thread_json = self.get_thread_json()
|
|
self.assertFalse(thread_json['is_hidden'])
|
|
self.assertFalse(thread_json['is_hidden'])
|
|
@@ -1113,12 +1073,10 @@ class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't hide other users theads in this category."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't hide other users theads in this category."
|
|
|
|
+ })
|
|
|
|
|
|
def test_hide_owned_thread_no_time(self):
|
|
def test_hide_owned_thread_no_time(self):
|
|
"""api forbids non-moderator from hiding other users threads"""
|
|
"""api forbids non-moderator from hiding other users threads"""
|
|
@@ -1141,12 +1099,10 @@ class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "You can't hide threads that are older than 1 minute."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "You can't hide threads that are older than 1 minute."
|
|
|
|
+ })
|
|
|
|
|
|
def test_hide_closed_category_no_permission(self):
|
|
def test_hide_closed_category_no_permission(self):
|
|
"""api test permission to hide thread in closed category"""
|
|
"""api test permission to hide thread in closed category"""
|
|
@@ -1167,12 +1123,10 @@ class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This category is closed. You can't hide threads in it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't hide threads in it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_hide_closed_thread_no_permission(self):
|
|
def test_hide_closed_thread_no_permission(self):
|
|
"""api test permission to hide closed thread"""
|
|
"""api test permission to hide closed thread"""
|
|
@@ -1193,12 +1147,10 @@ class ThreadHideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This thread is closed. You can't hide it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't hide it."
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
class ThreadUnhideApiTests(ThreadPatchApiTestCase):
|
|
class ThreadUnhideApiTests(ThreadPatchApiTestCase):
|
|
@@ -1265,12 +1217,10 @@ class ThreadUnhideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This category is closed. You can't reveal threads in it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This category is closed. You can't reveal threads in it."
|
|
|
|
+ })
|
|
|
|
|
|
def test_unhide_closed_thread_no_permission(self):
|
|
def test_unhide_closed_thread_no_permission(self):
|
|
"""api test permission to unhide closed thread"""
|
|
"""api test permission to unhide closed thread"""
|
|
@@ -1291,12 +1241,10 @@ class ThreadUnhideApiTests(ThreadPatchApiTestCase):
|
|
},
|
|
},
|
|
]
|
|
]
|
|
)
|
|
)
|
|
- self.assertEqual(response.status_code, 400)
|
|
|
|
-
|
|
|
|
- response_json = response.json()
|
|
|
|
- self.assertEqual(
|
|
|
|
- response_json['detail'][0], "This thread is closed. You can't reveal it."
|
|
|
|
- )
|
|
|
|
|
|
+ self.assertEqual(response.status_code, 403)
|
|
|
|
+ self.assertEqual(response.json(), {
|
|
|
|
+ 'detail': "This thread is closed. You can't reveal it."
|
|
|
|
+ })
|
|
|
|
|
|
|
|
|
|
class ThreadSubscribeApiTests(ThreadPatchApiTestCase):
|
|
class ThreadSubscribeApiTests(ThreadPatchApiTestCase):
|