Skip to content

Commit

Permalink
Remove confusing warning messaegs slackapi#1030
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Jun 10, 2021
1 parent 0a7918a commit 0413fea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
19 changes: 16 additions & 3 deletions slack_sdk/models/blocks/block_elements.py
Expand Up @@ -149,10 +149,17 @@ def __init__(
subtype: Optional[str] = None,
**others: dict,
):
"""An interactive block element.
We generally recommend using the concrete subclasses for better supports of available properties.
"""
if subtype:
self._subtype_warning()
super().__init__(type=type or subtype)
show_unknown_key_warning(self, others)

# Note that we don't intentionally have show_unknown_key_warning for the unknown key warnings here.
# It's fine to pass any kwargs to the held dict here although the class does not do any validation.
# show_unknown_key_warning(self, others)

self.action_id = action_id

Expand Down Expand Up @@ -190,11 +197,17 @@ def __init__(
confirm: Optional[Union[dict, ConfirmObject]] = None,
**others: dict,
):
"""InteractiveElement that is usable in input blocks"""
"""InteractiveElement that is usable in input blocks
We generally recommend using the concrete subclasses for better supports of available properties.
"""
if subtype:
self._subtype_warning()
super().__init__(action_id=action_id, type=type or subtype)
show_unknown_key_warning(self, others)

# Note that we don't intentionally have show_unknown_key_warning for the unknown key warnings here.
# It's fine to pass any kwargs to the held dict here although the class does not do any validation.
# show_unknown_key_warning(self, others)

self.placeholder = TextObject.parse(placeholder)
self.confirm = ConfirmObject.parse(confirm)
Expand Down
22 changes: 22 additions & 0 deletions tests/slack_sdk/models/test_elements.py
Expand Up @@ -23,6 +23,8 @@
ChannelSelectElement,
ConfirmObject,
Option,
InputInteractiveElement,
InteractiveElement,
)
from . import STRING_3001_CHARS, STRING_301_CHARS

Expand All @@ -32,6 +34,26 @@
# -------------------------------------------------


class InteractiveElementTests(unittest.TestCase):
def test_with_interactive_element(self):
input = {
"type": "plain_text_input",
"action_id": "plain_input",
"placeholder": {"type": "plain_text", "text": "Enter some plain text"},
}
# Any properties should be lost
self.assertDictEqual(input, InteractiveElement(**input).to_dict())

def test_with_input_interactive_element(self):
input = {
"type": "plain_text_input",
"action_id": "plain_input",
"placeholder": {"type": "plain_text", "text": "Enter some plain text"},
}
# Any properties should be lost
self.assertDictEqual(input, InputInteractiveElement(**input).to_dict())


class InteractiveElementTests(unittest.TestCase):
def test_action_id(self):
with self.assertRaises(SlackObjectFormationError):
Expand Down

0 comments on commit 0413fea

Please sign in to comment.