[V3 Utils] Improve bordered function and add tests (#1206)

This commit is contained in:
Tobotimus
2018-01-13 11:15:34 +11:00
committed by GitHub
parent 1c504f681e
commit 05c5c58eaf
2 changed files with 98 additions and 21 deletions

48
tests/core/test_utils.py Normal file
View File

@@ -0,0 +1,48 @@
import textwrap
from redbot.core.utils import chat_formatting
def test_bordered_symmetrical():
expected = textwrap.dedent("""\
┌──────────────┐ ┌─────────────┐
│one │ │four │
│two │ │five │
│three │ │six │
└──────────────┘ └─────────────┘""")
col1, col2 = ['one', 'two', 'three'], ['four', 'five', 'six']
assert chat_formatting.bordered(col1, col2) == expected
def test_bordered_asymmetrical():
expected = textwrap.dedent("""\
┌──────────────┐ ┌──────────────┐
│one │ │four │
│two │ │five │
│three │ │six │
└──────────────┘ │seven │
└──────────────┘""")
col1, col2 = ['one', 'two', 'three'], ['four', 'five', 'six', 'seven']
assert chat_formatting.bordered(col1, col2) == expected
def test_bordered_asymmetrical_2():
expected = textwrap.dedent("""\
┌──────────────┐ ┌─────────────┐
│one │ │five │
│two │ │six │
│three │ └─────────────┘
│four │
└──────────────┘ """)
col1, col2 = ['one', 'two', 'three', 'four'], ['five', 'six']
assert chat_formatting.bordered(col1, col2) == expected
def test_bordered_ascii():
expected = textwrap.dedent("""\
---------------- ---------------
|one | |four |
|two | |five |
|three | |six |
---------------- ---------------""")
col1, col2 = ['one', 'two', 'three'], ['four', 'five', 'six']
assert chat_formatting.bordered(col1, col2, ascii_border=True) == expected