Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7c042a
commit 36f6603
Showing
2 changed files
with
43 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,71 @@ | ||
from slackblocks import Modal | ||
from slackblocks.blocks import DividerBlock, SectionBlock | ||
|
||
|
||
def test_modal_without_blocks() -> None: | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button" | ||
) | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button" | ||
) | ||
with open("test/samples/modal_without_blocks.json", "r") as expected: | ||
assert repr(modal) == expected.read() | ||
|
||
|
||
def test_modal_with_blocks() -> None: | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button", | ||
blocks=[ | ||
SectionBlock( | ||
text="first section block", | ||
block_id="1" | ||
), | ||
DividerBlock( | ||
block_id="2" | ||
), | ||
SectionBlock( | ||
text="second section block", | ||
block_id="3" | ||
) | ||
] | ||
) | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button", | ||
blocks=[ | ||
SectionBlock( | ||
text="first section block", | ||
block_id="1" | ||
), | ||
DividerBlock( | ||
block_id="2" | ||
), | ||
SectionBlock( | ||
text="second section block", | ||
block_id="3" | ||
) | ||
] | ||
) | ||
with open("test/samples/modal_with_blocks.json", "r") as expected: | ||
assert repr(modal) == expected.read() | ||
|
||
|
||
def test_to_dict() -> None: | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button", | ||
blocks=[ | ||
SectionBlock( | ||
text="first section block", | ||
block_id="1" | ||
) | ||
] | ||
) | ||
modal = Modal("Hello, world!", | ||
close="Close button", | ||
submit="Submit button", | ||
blocks=[ | ||
SectionBlock( | ||
text="first section block", | ||
block_id="1" | ||
) | ||
] | ||
) | ||
assert modal.to_dict() == { | ||
'type': 'modal', | ||
'type': 'modal', | ||
'title': { | ||
'type': 'plain_text', | ||
'text': 'Hello, world!' | ||
}, | ||
}, | ||
'close': { | ||
'type': 'plain_text', | ||
'text': 'Close button' | ||
}, | ||
}, | ||
'submit': { | ||
'type': 'plain_text', | ||
'text': 'Submit button' | ||
}, | ||
}, | ||
'blocks': [ | ||
{ | ||
'type': 'section', 'block_id': '1', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': 'first section block', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': 'first section block', | ||
'verbatim': False | ||
} | ||
} | ||
] | ||
} | ||
} |