Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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')
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')
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)
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
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
def append_text_to_block(self, block, text):
return block.children.add_new(TextBlock, title=text)