From 36f66030c7c4cc01a6cf23201d6f7d7a9f4f8824 Mon Sep 17 00:00:00 2001 From: nicklambourne Date: Wed, 13 Apr 2022 23:38:25 +1000 Subject: [PATCH] fmt2 --- slackblocks/modals.py | 3 +- test/test_modals.py | 81 ++++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/slackblocks/modals.py b/slackblocks/modals.py index f3ef741..e44d55b 100644 --- a/slackblocks/modals.py +++ b/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 @@ -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, diff --git a/test/test_modals.py b/test/test_modals.py index 634ba0c..e623572 100644 --- a/test/test_modals.py +++ b/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 } } ] - } \ No newline at end of file + }