-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for URLTextInput and EmailTextInput elements
- Loading branch information
Showing
5 changed files
with
122 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pytest>=6.0,<7.0 | ||
pydantic>=2,<3 | ||
pydantic[email]>=2,<3 | ||
black>=23.0 | ||
python-dateutil>=2.8,<3.0 |
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 |
---|---|---|
|
@@ -13,9 +13,9 @@ | |
EMAIL = "[email protected]" | ||
AUTHOR = "Dmitry Chernyshov" | ||
REQUIRES_PYTHON = ">=3.7.0" | ||
VERSION = "1.8.4" | ||
VERSION = "1.9.0" | ||
|
||
REQUIRED = ["pydantic>=2,<3"] | ||
REQUIRED = ["pydantic[email]>=2,<3"] | ||
EXTRAS = {"gen": ["black"]} | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
|
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
ConversationsSelect, | ||
DatePicker, | ||
DatetimePicker, | ||
EmailTextInput, | ||
ExternalSelect, | ||
FileInput, | ||
Image, | ||
|
@@ -28,6 +29,7 @@ | |
RichTextSection, | ||
StaticSelect, | ||
TimePicker, | ||
URLTextInput, | ||
UsersSelect, | ||
) | ||
from blockkit.objects import ( | ||
|
@@ -1580,3 +1582,60 @@ def test_fileinput_excessive_max_files_raises_exception(): | |
with pytest.raises(ValidationError): | ||
FileInput(max_files=11) | ||
|
||
|
||
def test_builds_email_text_input(): | ||
assert EmailTextInput( | ||
action_id="action_id", | ||
initial_value="[email protected]", | ||
dispatch_action_config=DispatchActionConfig( | ||
trigger_actions_on=["on_character_entered"] | ||
), | ||
focus_on_load=True, | ||
placeholder=PlainText(text="placeholder"), | ||
).build() == { | ||
"type": "email_text_input", | ||
"action_id": "action_id", | ||
"initial_value": "[email protected]", | ||
"dispatch_action_config": {"trigger_actions_on": ["on_character_entered"]}, | ||
"focus_on_load": True, | ||
"placeholder": {"type": "plain_text", "text": "placeholder"}, | ||
} | ||
|
||
|
||
def test_email_text_input_excessive_placeholder_raises_exception(): | ||
with pytest.raises(ValidationError): | ||
EmailTextInput(placeholder=PlainText(text="p" * 151)) | ||
|
||
|
||
def test_email_text_input_invalid_initial_value_raises_exception(): | ||
with pytest.raises(ValidationError): | ||
EmailTextInput(initial_value="dimabotsignals.co") | ||
|
||
|
||
def test_builds_url_text_input(): | ||
assert URLTextInput( | ||
action_id="action_id", | ||
initial_value="https://example.com/", | ||
dispatch_action_config=DispatchActionConfig( | ||
trigger_actions_on=["on_character_entered"] | ||
), | ||
focus_on_load=True, | ||
placeholder=PlainText(text="placeholder"), | ||
).build() == { | ||
"type": "url_text_input", | ||
"action_id": "action_id", | ||
"initial_value": "https://example.com/", | ||
"dispatch_action_config": {"trigger_actions_on": ["on_character_entered"]}, | ||
"focus_on_load": True, | ||
"placeholder": {"type": "plain_text", "text": "placeholder"}, | ||
} | ||
|
||
|
||
def test_url_text_input_excessive_placeholder_raises_exception(): | ||
with pytest.raises(ValidationError): | ||
URLTextInput(placeholder=PlainText(text="p" * 151)) | ||
|
||
|
||
def test_url_text_input_invalid_initial_value_raises_exception(): | ||
with pytest.raises(ValidationError): | ||
URLTextInput(initial_value="foo bar") |