Skip to content

Commit

Permalink
fmt2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklambourne committed Apr 13, 2022
1 parent c7c042a commit 36f6603
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 41 deletions.
3 changes: 1 addition & 2 deletions slackblocks/modals.py
@@ -1,7 +1,6 @@
from abc import abstractmethod
from json import dumps
from typing import Any, Dict, List, Optional, Union
from .attachments import Attachment
from .blocks import Block
from .elements import Text
from enum import Enum
Expand All @@ -18,7 +17,7 @@ class ModalType(Enum):
class Modal:
"""
A Slack modal object that can be converted into JSON
for use with the Slack API
for use with the Slack API
"""

def __init__(self,
Expand Down
81 changes: 42 additions & 39 deletions test/test_modals.py
@@ -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
}
}
]
}
}

0 comments on commit 36f6603

Please sign in to comment.