Add more tests for utils

Co-authored-by: Nadir Chowdhury <chowdhurynadir0@outlook.com>
This commit is contained in:
Sebastian Law 2022-03-07 14:10:28 -08:00 committed by GitHub
parent 3c78b03aa3
commit caa816a636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,6 +137,21 @@ def test_resolve_invite(url, code):
assert utils.resolve_invite(url).code == code
@pytest.mark.parametrize(
('url', 'event_id'),
[
('https://discordapp.com/invite/dpy', None),
('https://discord.com/invite/dpy', None),
('https://discord.gg/dpy', None),
('https://discordapp.com/invite/dpy?event=22222222', 22222222),
('https://discord.com/invite/dpy?event=4098', 4098),
('https://discord.gg/dpy?event=727', 727),
],
)
def test_resolve_invite_event(url, event_id: typing.Optional[int]):
assert utils.resolve_invite(url).event == event_id
@pytest.mark.parametrize(
('url', 'code'),
[
@ -149,7 +164,7 @@ def test_resolve_template(url, code):
assert utils.resolve_template(url) == code
@pytest.mark.parametrize('mention', ['@everyone', '@here'])
@pytest.mark.parametrize('mention', ['@everyone', '@here', '<@80088516616269824>', '<@!80088516616269824>', '<@&381978264698224660>'])
def test_escape_mentions(mention):
assert mention not in utils.escape_mentions(mention)
assert mention not in utils.escape_mentions(f"one {mention} two")