def test_document(self): input = { "type": "datepicker", "action_id": "datepicker123", "initial_date": "1990-04-28", "placeholder": { "type": "plain_text", "text": "Select a date" }, "confirm": { "title": { "type": "plain_text", "text": "Are you sure?" }, "text": { "type": "mrkdwn", "text": "Wouldn't you prefer a good game of _chess_?", }, "confirm": { "type": "plain_text", "text": "Do it" }, "deny": { "type": "plain_text", "text": "Stop, I've changed my mind!" }, }, } self.assertDictEqual(input, DatePickerElement(**input).to_dict())
def test_focus_on_load(self): input = { "type": "datepicker", "action_id": "datepicker123", "initial_date": "1990-04-28", "placeholder": { "type": "plain_text", "text": "Select a date" }, "focus_on_load": True, } self.assertDictEqual(input, DatePickerElement(**input).to_dict())
def test_json(self): for month in range(1, 12): for day in range(1, 31): date = f"2020-{month:02}-{day:02}" self.assertDictEqual( { "action_id": "datepicker-action", "initial_date": date, "placeholder": { "emoji": True, "text": "Select a date", "type": "plain_text", }, "type": "datepicker", }, DatePickerElement( action_id="datepicker-action", placeholder="Select a date", initial_date=date, ).to_dict(), )
def test_issue_623(self): elem = DatePickerElement(action_id="1", placeholder=None) elem.to_dict() # no exception elem = DatePickerElement(action_id="1") elem.to_dict() # no exception with self.assertRaises(SlackObjectFormationError): elem = DatePickerElement(action_id="1", placeholder="12345" * 100) elem.to_dict()