-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 6.6.x maintenance branch after 6.6.2 release
Keeping master up-to-date as we go should minimize the risk of merge conflicts later, when the 6.6.x sequence is finished and we jump into the 7's with both feet.
- Loading branch information
Showing
11 changed files
with
207 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# coding=utf-8 | ||
"""Tests sopel.tools""" | ||
from __future__ import unicode_literals, absolute_import, print_function, division | ||
|
||
|
||
from sopel import tools | ||
|
||
|
||
def test_get_sendable_message_default(): | ||
initial = 'aaaa' | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == initial | ||
assert excess == '' | ||
|
||
|
||
def test_get_sendable_message_limit(): | ||
initial = 'a' * 400 | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == initial | ||
assert excess == '' | ||
|
||
|
||
def test_get_sendable_message_excess(): | ||
initial = 'a' * 401 | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == 'a' * 400 | ||
assert excess == 'a' | ||
|
||
|
||
def test_get_sendable_message_excess_space(): | ||
# aaa...aaa bbb...bbb | ||
initial = ' '.join(['a' * 200, 'b' * 200]) | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == 'a' * 200 | ||
assert excess == 'b' * 200 | ||
|
||
|
||
def test_get_sendable_message_excess_space_limit(): | ||
# aaa...aaa bbb...bbb | ||
initial = ' '.join(['a' * 400, 'b' * 200]) | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == 'a' * 400 | ||
assert excess == 'b' * 200 | ||
|
||
|
||
def test_get_sendable_message_excess_bigger(): | ||
# aaa...aaa bbb...bbb | ||
initial = ' '.join(['a' * 401, 'b' * 1000]) | ||
text, excess = tools.get_sendable_message(initial) | ||
|
||
assert text == 'a' * 400 | ||
assert excess == 'a ' + 'b' * 1000 | ||
|
||
|
||
def test_get_sendable_message_optional(): | ||
text, excess = tools.get_sendable_message('aaaa', 3) | ||
assert text == 'aaa' | ||
assert excess == 'a' | ||
|
||
text, excess = tools.get_sendable_message('aaa bbb', 3) | ||
assert text == 'aaa' | ||
assert excess == 'bbb' | ||
|
||
text, excess = tools.get_sendable_message('aa bb cc', 3) | ||
assert text == 'aa' | ||
assert excess == 'bb cc' | ||
|
||
|
||
def test_get_sendable_message_two_bytes(): | ||
text, excess = tools.get_sendable_message('αααα', 4) | ||
assert text == 'αα' | ||
assert excess == 'αα' | ||
|
||
text, excess = tools.get_sendable_message('αααα', 5) | ||
assert text == 'αα' | ||
assert excess == 'αα' | ||
|
||
text, excess = tools.get_sendable_message('α ααα', 4) | ||
assert text == 'α' | ||
assert excess == 'ααα' | ||
|
||
text, excess = tools.get_sendable_message('αα αα', 4) | ||
assert text == 'αα' | ||
assert excess == 'αα' | ||
|
||
text, excess = tools.get_sendable_message('ααα α', 4) | ||
assert text == 'αα' | ||
assert excess == 'α α' |