diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2017-09-26 22:19:18 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2017-10-08 23:58:49 +0200 |
commit | 4c63a2103635fb7ab8b19dbcbbc8d9df167542d5 (patch) | |
tree | 786c811eb99b9a2236d7f40df3dc3264325e3e35 /_pytest/test_topic_command.py | |
parent | d6fb56faf85dd1abbb8789295c290c162a02067f (diff) | |
download | wee-slack-4c63a2103635fb7ab8b19dbcbbc8d9df167542d5.tar.gz |
refactor: Split topic_command_cb and add tests
Split out the parts of topic_command_cb that's most interesting and
easiest to test into parse_topic_command and add tests for that
function.
Diffstat (limited to '_pytest/test_topic_command.py')
-rw-r--r-- | _pytest/test_topic_command.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/_pytest/test_topic_command.py b/_pytest/test_topic_command.py new file mode 100644 index 0000000..2a4f069 --- /dev/null +++ b/_pytest/test_topic_command.py @@ -0,0 +1,44 @@ +from wee_slack import parse_topic_command + + +def test_parse_topic_without_arguments(): + channel_name, topic = parse_topic_command('/topic') + + assert channel_name is None + assert topic is None + + +def test_parse_topic_with_text(): + channel_name, topic = parse_topic_command('/topic some topic text') + + assert channel_name is None + assert topic == 'some topic text' + + +def test_parse_topic_with_delete(): + channel_name, topic = parse_topic_command('/topic -delete') + + assert channel_name is None + assert topic == '' + + +def test_parse_topic_with_channel(): + channel_name, topic = parse_topic_command('/topic #general') + + assert channel_name == 'general' + assert topic is None + + +def test_parse_topic_with_channel_and_text(): + channel_name, topic = parse_topic_command( + '/topic #general some topic text') + + assert channel_name == 'general' + assert topic == 'some topic text' + + +def test_parse_topic_with_channel_and_delete(): + channel_name, topic = parse_topic_command('/topic #general -delete') + + assert channel_name == 'general' + assert topic == '' |