How to use the notion.block.TextBlock function in notion

To help you get started, we’ve selected a few notion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cobertos / md2notion / tests / test_NotionPyRenderer.py View on Github external
def test_imageBlockText():
    '''it should render an image in bold text'''
    #arrange/act
    output = mistletoe.markdown("**texttext![](https://via.placeholder.com/500)texttext**", NotionPyRenderer)

    #assert
    assert len(output) == 2
    assert isinstance(output[0], dict)
    assert output[0]['type'] == notion.block.TextBlock
    assert output[0]['title'] == "**texttexttexttext**" #Should extract the image
    assert isinstance(output[1], dict) #The ImageBlock can't be inline with anything else so it comes out
    assert output[1]['type'] == notion.block.ImageBlock
github Cobertos / md2notion / tests / test_upload.py View on Github external
def test_uploadBlock():
    '''uploads a simple block to Notion using add_new'''
    #arrange
    blockDescriptor = {
        'type': TextBlock,
        'title': 'This is a test of the test system'
    }
    notionBlock = Mock()
    notionBlock.children.add_new = Mock()

    #act
    uploadBlock(blockDescriptor, notionBlock, '')

    #assert
    notionBlock.children.add_new.assert_called_with(TextBlock, title='This is a test of the test system')
github Cobertos / md2notion / tests / test_upload.py View on Github external
def test_uploadBlock():
    '''uploads a simple block to Notion using add_new'''
    #arrange
    blockDescriptor = {
        'type': TextBlock,
        'title': 'This is a test of the test system'
    }
    notionBlock = Mock()
    notionBlock.children.add_new = Mock()

    #act
    uploadBlock(blockDescriptor, notionBlock, '')

    #assert
    notionBlock.children.add_new.assert_called_with(TextBlock, title='This is a test of the test system')
github kevinjalbert / notion-toolbox / server / src / task_processors / track_transition_processor.py View on Github external
def _create_transition(self, toggle_block, task):
        transition_string = "{}, {}".format(task.status, self._format_date_time(datetime.now()))
        toggle_block.children.add_new(TextBlock, title=transition_string)
github Cobertos / md2notion / md2notion / NotionPyRenderer.py View on Github external
def toString(renderedBlock):
            if isinstance(renderedBlock, dict) and renderedBlock['type'] == TextBlock:
                return renderedBlock['title'] #This unwraps TextBlocks/paragraphs to use in other blocks
            else: #Returns str as-is or returns blocks we can't convert
                return renderedBlock
github kevinjalbert / notion-toolbox / shared / notionscripts / notion_api.py View on Github external
def append_to_current_day_notes(self, content):
        # Get the divider block that signifies the end of the notes for the current day
        divider_block = [x for x in self.current_day().children if type(x) == DividerBlock][0]

        # Add note to end of the page, then move it to before the divider
        note_block = self.current_day().children.add_new(TextBlock, title=content)
        note_block.move_to(divider_block, "before")

        return note_block
github kevinjalbert / notion-toolbox / shared / notionscripts / notion_api.py View on Github external
def append_text_to_block(self, block, text):
        return block.children.add_new(TextBlock, title=text)