From 373baece5094b5bedf10e08ea95d09be3619fd23 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 20 Mar 2021 13:41:02 +0100 Subject: Format all python files with black --- _pytest/test_unfurl.py | 325 +++++++++++++++++++++++++------------------------ 1 file changed, 166 insertions(+), 159 deletions(-) (limited to '_pytest/test_unfurl.py') diff --git a/_pytest/test_unfurl.py b/_pytest/test_unfurl.py index eb8fe27..e8043a8 100644 --- a/_pytest/test_unfurl.py +++ b/_pytest/test_unfurl.py @@ -6,166 +6,173 @@ import time import wee_slack import os -os.environ['TZ'] = 'UTC' +os.environ["TZ"] = "UTC" -@pytest.mark.parametrize('case', ( - { - 'input': "foo", - 'output': "foo", - }, - { - 'input': "", - 'output': "@channel", - }, - { - 'input': "", - 'output': "@everyone", - }, - { - 'input': "", - 'output': "@group", - }, - { - 'input': "", - 'output': "@here", - }, - { - 'input': "<@U407ABLLW|@othernick>: foo", - 'output': "@alice: foo", - }, - { - 'input': "<@UNKNOWN|@othernick>: foo", - 'output': "@othernick: foo", - }, - { - 'input': "foo <#C407ABS94|otherchannel> foo", - 'output': "foo #general foo", - }, - { - 'input': "foo <#UNKNOWN|otherchannel> foo", - 'output': "foo #otherchannel foo", - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com suffix", - 'ignore_alt_text': True, - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com (example) suffix", - 'auto_link_display': 'both', - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com (example with spaces) suffix", - 'auto_link_display': 'both', - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com (example.com) suffix", - 'auto_link_display': 'both', - }, - { - 'input': "url: suffix", - 'output': "url: mailto:name@example.com (name@example.com) suffix", - 'auto_link_display': 'both', - }, - { - 'input': "url: suffix", - 'output': "url: example.com suffix", - 'auto_link_display': 'text', - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com (different text) suffix", - 'auto_link_display': 'text', - }, - { - 'input': "url: suffix", - 'output': "url: name@example.com suffix", - 'auto_link_display': 'text', - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com (different text) suffix", - 'auto_link_display': 'url', - }, - { - 'input': "url: suffix", - 'output': "url: https://example.com suffix", - 'auto_link_display': 'url', - }, - { - 'input': "url: suffix", - 'output': "url: mailto:name@example.com suffix", - 'auto_link_display': 'url', - }, - { - 'input': "<@U407ABLLW> multiple unfurl ", - 'output': "@alice multiple unfurl https://example.com (example with spaces)", - 'auto_link_display': 'both', - }, - { - 'input': "url with equal fallback: suffix", - 'output': "url with equal fallback: https://example.com suffix", - 'auto_link_display': 'both', - }, - { - 'input': "try the #general channel", - 'output': "try the #general channel", - }, - { - 'input': "<@U407ABLLW> I think 3 > 2", - 'output': "@alice I think 3 > 2", - }, - { - 'input': " This is announcement for the dev team", - 'output': "@test This is announcement for the dev team" - }, - { - 'input': " This is announcement for the dev team", - 'output': "@othersubteam This is announcement for the dev team" - }, - { - 'input': "Ends .", - 'output': "Ends 2020-01-01 - January 01, 2020 - Jan 01, 2020 - Wednesday, January 01, 2020." - }, - { - 'input': "Ends .", - 'output': "Ends 12:00 - 12:00:00." - }, - { - 'input': "Ends .", - 'output': "Ends 2020-01-01 {invalid_token}." - }, - { - 'input': "Ends .", - 'output': "Ends 2020-01-01 (http://github.com)." - }, - { - 'input': "Ends .".format( - int(time.mktime(datetime.today().timetuple()))), - 'output': "Ends today - today - today." - }, - { - 'input': "Ends .".format( - int(time.mktime((datetime.today() - timedelta(days=1)).timetuple()))), - 'output': "Ends yesterday - yesterday - yesterday." - }, - { - 'input': "Ends .".format( - int(time.mktime((datetime.today() + timedelta(days=1)).timetuple()))), - 'output': "Ends tomorrow - tomorrow - tomorrow." - }, - { - 'input': "Ends .", - 'output': "Ends January 01, 2020 - Jan 01, 2020 - Wednesday, January 01, 2020." - } -)) + +@pytest.mark.parametrize( + "case", + ( + { + "input": "foo", + "output": "foo", + }, + { + "input": "", + "output": "@channel", + }, + { + "input": "", + "output": "@everyone", + }, + { + "input": "", + "output": "@group", + }, + { + "input": "", + "output": "@here", + }, + { + "input": "<@U407ABLLW|@othernick>: foo", + "output": "@alice: foo", + }, + { + "input": "<@UNKNOWN|@othernick>: foo", + "output": "@othernick: foo", + }, + { + "input": "foo <#C407ABS94|otherchannel> foo", + "output": "foo #general foo", + }, + { + "input": "foo <#UNKNOWN|otherchannel> foo", + "output": "foo #otherchannel foo", + }, + { + "input": "url: suffix", + "output": "url: https://example.com suffix", + "ignore_alt_text": True, + }, + { + "input": "url: suffix", + "output": "url: https://example.com (example) suffix", + "auto_link_display": "both", + }, + { + "input": "url: suffix", + "output": "url: https://example.com (example with spaces) suffix", + "auto_link_display": "both", + }, + { + "input": "url: suffix", + "output": "url: https://example.com (example.com) suffix", + "auto_link_display": "both", + }, + { + "input": "url: suffix", + "output": "url: mailto:name@example.com (name@example.com) suffix", + "auto_link_display": "both", + }, + { + "input": "url: suffix", + "output": "url: example.com suffix", + "auto_link_display": "text", + }, + { + "input": "url: suffix", + "output": "url: https://example.com (different text) suffix", + "auto_link_display": "text", + }, + { + "input": "url: suffix", + "output": "url: name@example.com suffix", + "auto_link_display": "text", + }, + { + "input": "url: suffix", + "output": "url: https://example.com (different text) suffix", + "auto_link_display": "url", + }, + { + "input": "url: suffix", + "output": "url: https://example.com suffix", + "auto_link_display": "url", + }, + { + "input": "url: suffix", + "output": "url: mailto:name@example.com suffix", + "auto_link_display": "url", + }, + { + "input": "<@U407ABLLW> multiple unfurl ", + "output": "@alice multiple unfurl https://example.com (example with spaces)", + "auto_link_display": "both", + }, + { + "input": "url with equal fallback: suffix", + "output": "url with equal fallback: https://example.com suffix", + "auto_link_display": "both", + }, + { + "input": "try the #general channel", + "output": "try the #general channel", + }, + { + "input": "<@U407ABLLW> I think 3 > 2", + "output": "@alice I think 3 > 2", + }, + { + "input": " This is announcement for the dev team", + "output": "@test This is announcement for the dev team", + }, + { + "input": " This is announcement for the dev team", + "output": "@othersubteam This is announcement for the dev team", + }, + { + "input": "Ends .", + "output": "Ends 2020-01-01 - January 01, 2020 - Jan 01, 2020 - Wednesday, January 01, 2020.", + }, + { + "input": "Ends .", + "output": "Ends 12:00 - 12:00:00.", + }, + { + "input": "Ends .", + "output": "Ends 2020-01-01 {invalid_token}.", + }, + { + "input": "Ends .", + "output": "Ends 2020-01-01 (http://github.com).", + }, + { + "input": "Ends .".format( + int(time.mktime(datetime.today().timetuple())) + ), + "output": "Ends today - today - today.", + }, + { + "input": "Ends .".format( + int(time.mktime((datetime.today() - timedelta(days=1)).timetuple())) + ), + "output": "Ends yesterday - yesterday - yesterday.", + }, + { + "input": "Ends .".format( + int(time.mktime((datetime.today() + timedelta(days=1)).timetuple())) + ), + "output": "Ends tomorrow - tomorrow - tomorrow.", + }, + { + "input": "Ends .", + "output": "Ends January 01, 2020 - Jan 01, 2020 - Wednesday, January 01, 2020.", + }, + ), +) def test_unfurl_refs(case, realish_eventrouter): wee_slack.EVENTROUTER = realish_eventrouter - wee_slack.config.unfurl_ignore_alt_text = case.get('ignore_alt_text') - wee_slack.config.unfurl_auto_link_display = case.get('auto_link_display') + wee_slack.config.unfurl_ignore_alt_text = case.get("ignore_alt_text") + wee_slack.config.unfurl_auto_link_display = case.get("auto_link_display") - result = wee_slack.unfurl_refs(case['input']) - assert result == case['output'] + result = wee_slack.unfurl_refs(case["input"]) + assert result == case["output"] -- cgit