aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_unfurl.py
diff options
context:
space:
mode:
authorMatt Robenolt <matt@ydekproductions.com>2016-11-07 11:43:40 -0800
committerMatt Robenolt <matt@ydekproductions.com>2016-11-07 11:43:40 -0800
commitb610bfae9230a954fd4547c8ef0ef28036d8eccc (patch)
treee57c34e93d80c0f4ea4e90efc4d9ae45bee278b3 /_pytest/test_unfurl.py
parent6fbbaeb50d42cf1fd6411b990dde43781154a2a1 (diff)
downloadwee-slack-b610bfae9230a954fd4547c8ef0ef28036d8eccc.tar.gz
Leverage pytest.parametrize for test_unfurl
This provides nicer granular test cases rather than one whole test that fails.
Diffstat (limited to '_pytest/test_unfurl.py')
-rw-r--r--_pytest/test_unfurl.py53
1 files changed, 27 insertions, 26 deletions
diff --git a/_pytest/test_unfurl.py b/_pytest/test_unfurl.py
index 2b80eda..2168aed 100644
--- a/_pytest/test_unfurl.py
+++ b/_pytest/test_unfurl.py
@@ -1,36 +1,41 @@
import wee_slack
import pytest
-import json
slack = wee_slack
-unfurl_map = [
- { "input": "foo",
- "output": "foo",
+
+@pytest.mark.parametrize('case', (
+ {
+ 'input': "foo",
+ 'output': "foo",
},
- { "input": "<@U2147483697|@othernick>: foo",
- "output": "@testuser: foo",
- "ignore_alt_text": True
+ {
+ 'input': "<@U2147483697|@othernick>: foo",
+ 'output': "@testuser: foo",
+ 'ignore_alt_text': True,
},
- { "input": "foo <#C2147483705|#otherchannel> foo",
- "output": "foo #otherchannel foo",
+ {
+ 'input': "foo <#C2147483705|#otherchannel> foo",
+ 'output': "foo #otherchannel foo",
},
- { "input": "foo <#C2147483705> foo",
- "output": "foo #testchan foo",
+ {
+ 'input': "foo <#C2147483705> foo",
+ 'output': "foo #testchan foo",
},
- { "input": "url: <https://example.com|example> suffix",
- "output": "url: https://example.com (example) suffix",
+ {
+ 'input': "url: <https://example.com|example> suffix",
+ 'output': "url: https://example.com (example) suffix",
},
- { "input": "url: <https://example.com|example with spaces> suffix",
- "output": "url: https://example.com (example with spaces) suffix",
+ {
+ 'input': "url: <https://example.com|example with spaces> suffix",
+ 'output': "url: https://example.com (example with spaces) suffix",
},
- { "input": "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>",
- "output": "@othernick multiple unfurl https://example.com (example with spaces)",
+ {
+ 'input': "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>",
+ 'output': "@othernick multiple unfurl https://example.com (example with spaces)",
},
- ]
-
-
-def test_unfurl_refs(myservers, mychannels, myusers):
+))
+def test_unfurl_refs(myservers, mychannels, myusers, case):
slack.servers = myservers
slack.channels = mychannels
slack.users = myusers
@@ -38,8 +43,4 @@ def test_unfurl_refs(myservers, mychannels, myusers):
slack.servers[0].users = myusers
print mychannels[0].identifier
- for k in unfurl_map:
- if "ignore_alt_text" in k:
- assert slack.unfurl_refs(k["input"], ignore_alt_text=k["ignore_alt_text"]) == k["output"]
- else:
- assert slack.unfurl_refs(k["input"]) == k["output"]
+ assert slack.unfurl_refs(case['input'], ignore_alt_text=case.get('ignore_alt_text', False)) == case['output']