mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added possibility to use HashTag/CashTag elements without prefixing content, added sep: str argument to the as_line function.
This commit is contained in:
parent
afeb659b82
commit
853b72f38d
2 changed files with 75 additions and 2 deletions
|
|
@ -276,6 +276,42 @@ class TestNode:
|
|||
)
|
||||
|
||||
|
||||
class TestHashTag:
|
||||
def test_only_one_element_in_body(self):
|
||||
with pytest.raises(ValueError):
|
||||
HashTag("test", "test")
|
||||
|
||||
def test_body_is_not_str(self):
|
||||
with pytest.raises(ValueError):
|
||||
HashTag(Text("test"))
|
||||
|
||||
def test_with_no_prefix(self):
|
||||
node = HashTag("test")
|
||||
assert node._body == ("#test",)
|
||||
|
||||
def test_with_prefix(self):
|
||||
node = HashTag("#test")
|
||||
assert node._body == ("#test",)
|
||||
|
||||
|
||||
class TestCashTag:
|
||||
def test_only_one_element_in_body(self):
|
||||
with pytest.raises(ValueError):
|
||||
CashTag("test", "test")
|
||||
|
||||
def test_body_is_not_str(self):
|
||||
with pytest.raises(ValueError):
|
||||
CashTag(Text("test"))
|
||||
|
||||
def test_with_no_prefix(self):
|
||||
node = CashTag("USD")
|
||||
assert node._body == ("$USD",)
|
||||
|
||||
def test_with_prefix(self):
|
||||
node = CashTag("$USD")
|
||||
assert node._body == ("$USD",)
|
||||
|
||||
|
||||
class TestUtils:
|
||||
def test_apply_entity(self):
|
||||
node = _apply_entity(
|
||||
|
|
@ -289,6 +325,16 @@ class TestUtils:
|
|||
assert isinstance(node, Text)
|
||||
assert len(node._body) == 4 # 3 + '\n'
|
||||
|
||||
def test_line_with_sep(self):
|
||||
node = as_line("test", "test", "test", sep=" ")
|
||||
assert isinstance(node, Text)
|
||||
assert len(node._body) == 6 # 3 + 2 * ' ' + '\n'
|
||||
|
||||
def test_as_line_single_element_with_sep(self):
|
||||
node = as_line("test", sep=" ")
|
||||
assert isinstance(node, Text)
|
||||
assert len(node._body) == 2 # 1 + '\n'
|
||||
|
||||
def test_as_list(self):
|
||||
node = as_list("test", "test", "test")
|
||||
assert isinstance(node, Text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue