def view_attributes(): return { "blocks": [PlainText("text")], "private_metadata": '{"data": "OK"}', "callback_id": "callback_id", "external_id": "external_id", }
def _make_confirm(): return ConfirmationDialog( text_object=PlainText("text"), title="title", confirm="confirm", deny="deny", )
class MockFixedButton(FixedButton): action_id = "test_action" text = "text" value = "value" url = "http://crispy.dev" confirm = ConfirmationDialog( text_object=PlainText("text"), title="title", confirm="confirm", deny="deny", ) style = Button.Styles.DEFAULT
class TestFixedButton: def test_fixed(self, snapshot): snapshot.assert_match(MockFixedButton()) @pytest.mark.parametrize( "field, value", [ ("action_id", "override"), ("value", "override"), ( "confirm", ConfirmationDialog( text_object=PlainText("override"), title="override", confirm="confirm", deny="deny", ), ), ("text", "override"), ("style", Button.Styles.DANGER), ], ) def test_override(self, snapshot, field, value): snapshot.assert_match(MockFixedButton(**{field: value}))
def test_validate_elements(self): with pytest.raises(ValidationError): Context(elements=[PlainText(str(i)) for i in range(11)])
def test(self, snapshot): snapshot.assert_match( Context(block_id="block_id", elements=[PlainText("text")]))
def test_validate_fields(self, attributes): del attributes["text_object"] attributes["fields"] = [PlainText(str(i)) for i in range(11)] with pytest.raises(ValidationError): Section(**attributes)
def test_fields(self, attributes, snapshot): del attributes["text_object"] attributes["fields"] = [PlainText("text")] snapshot.assert_match(Section(**attributes))
def attributes(self): return { "block_id": "block_id", "text_object": PlainText("text"), "accessory": MockElement(), }