mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 23:45:04 -04:00
Use literals in place of HTTPStatus
constants in tests (#13488)
* Use literals in place of `HTTPStatus` constants in tests * newsfile * code style * code style
This commit is contained in:
parent
51c01d450a
commit
2281427175
12 changed files with 177 additions and 447 deletions
|
@ -11,7 +11,6 @@
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import List
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
@ -94,7 +93,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
@override_config({"server_notices": {"system_mxid_localpart": "notices"}})
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
|
@ -106,7 +105,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"Server notices can only be sent to local users", channel.json_body["error"]
|
||||
)
|
||||
|
@ -122,7 +121,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_JSON, channel.json_body["errcode"])
|
||||
|
||||
# no content
|
||||
|
@ -133,7 +132,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
content={"user_id": self.other_user},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# no body
|
||||
|
@ -144,7 +143,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
content={"user_id": self.other_user, "content": ""},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual("'body' not in content", channel.json_body["error"])
|
||||
|
||||
|
@ -156,7 +155,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
content={"user_id": self.other_user, "content": {"body": ""}},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual("'msgtype' not in content", channel.json_body["error"])
|
||||
|
||||
|
@ -172,7 +171,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Server notices are not enabled on this server", channel.json_body["error"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue