Beispiel #1
0
def test_video_block(notion):
    block = notion.root_page.children.add_new(VideoBlock)
    assert_block_is_okay(**locals(), type="video")

    source = "https://streamable.com/8ud2kh"

    assert_block_attributes(block, source=source, caption="caption")
Beispiel #2
0
def test_bookmark_block(notion):
    block = notion.root_page.children.add_new(BookmarkBlock)
    assert_block_is_okay(**locals(), type="bookmark")

    assert block.link == ""
    assert block.title == ""
    assert block.source == ""
    assert block.description == ""
    assert block.bookmark_icon is None
    assert block.bookmark_cover is None

    link = "github.com/arturtamborski/notion-py/"
    block.set_new_link(link)
    block.refresh()

    assert block.link == link
    assert block.title == "arturtamborski/notion-py"
    assert "This is a fork of the" in block.description
    assert "https://" in block.bookmark_icon
    assert "https://" in block.bookmark_cover

    block.set_source_url(link)
    block.refresh()

    assert block.source == link
    assert block.display_source == link
Beispiel #3
0
def test_page_block(notion):
    block = notion.root_page.children.add_new(PageBlock)
    assert_block_is_okay(**locals(), type="page")
    cover = "/images/page-cover/woodcuts_3.jpg"
    assert_block_attributes(
        block, title="numbered_list", cover=cover, color="blue", icon="✔️"
    )
Beispiel #4
0
def test_image_block(notion):
    block = notion.root_page.children.add_new(ImageBlock)
    assert_block_is_okay(**locals(), type="image")

    source = "https://raw.githubusercontent.com/jamalex/"
    source = source + "notion-py/master/ezgif-3-a935fdcb7415.gif"

    assert_block_attributes(block, source=source, caption="caption")
Beispiel #5
0
def test_block(notion):
    # create basic block from existing page
    block = Block(notion.client, notion.root_page.id)
    parent = notion.root_page.parent
    assert_block_is_okay(**locals(), type="page")

    assert len(block.children) == 0
    assert len(block.parent.id) == 36
    assert block.id == notion.root_page.id
Beispiel #6
0
def test_column_block(notion):
    block = notion.root_page.children.add_new(ColumnBlock)
    assert_block_is_okay(**locals(), type="column")

    assert block.column_ratio is None
    assert len(block.children) == 0

    block.column_ratio = 1 / 2
    block.refresh()

    assert block.column_ratio == 1 / 2
Beispiel #7
0
def test_embed_block(notion):
    block = notion.root_page.children.add_new(EmbedBlock)
    assert_block_is_okay(**locals(), type="embed")

    assert block.source == ""
    assert block.caption == ""

    caption = "block embed caption"
    block.caption = caption
    block.refresh()

    assert block.caption == caption
Beispiel #8
0
def test_column_list_block(notion):
    block = notion.root_page.children.add_new(ColumnListBlock)
    assert_block_is_okay(**locals(), type="column_list")

    assert len(block.children) == 0

    block.children.add_new(ColumnBlock)
    block.children.add_new(ColumnBlock)
    block.evenly_space_columns()
    block.refresh()

    assert len(block.children) == 2
    assert block.children[0].column_ratio == 1 / 2
Beispiel #9
0
def test_file_block(notion):
    block = notion.root_page.children.add_new(FileBlock)
    assert_block_is_okay(**locals(), type="file")

    assert block.title == ""
    assert block.source == ""
    assert block.file_id is None

    title = "requirements.txt"
    block.upload_file(title)
    block.title = title
    block.refresh()

    assert block.title == title
    assert "secure.notion-static.com" in block.source
    assert len(block.file_id) == 36
Beispiel #10
0
def test_code_block(notion):
    block = notion.root_page.children.add_new(CodeBlock)
    assert_block_is_okay(**locals(), type="code")
    assert_block_attributes(block, color="blue", language="Erlang", title="code")
Beispiel #11
0
def test_callout_block(notion):
    block = notion.root_page.children.add_new(CalloutBlock)
    assert_block_is_okay(**locals(), type="callout")
    assert_block_attributes(block, icon="✔️", color="blue", title="callout")
Beispiel #12
0
def test_bulleted_list_block(notion):
    block = notion.root_page.children.add_new(BulletedListBlock)
    assert_block_is_okay(**locals(), type="bulleted_list")
    assert_block_attributes(block, title="bulleted_list")
Beispiel #13
0
def test_codepen_block(notion):
    block = notion.root_page.children.add_new(CodepenBlock)
    assert_block_is_okay(**locals(), type="codepen")
    source = "https://codepen.io/MrWeb123/pen/QWyeQwp"
    assert_block_attributes(block, source=source, caption="caption")
Beispiel #14
0
def test_toggle_block(notion):
    block = notion.root_page.children.add_new(ToggleBlock)
    assert_block_is_okay(**locals(), type="toggle")
    assert_block_attributes(block, title="text", color="blue")
Beispiel #15
0
def test_drive_block(notion):
    block = notion.root_page.children.add_new(DriveBlock)
    assert_block_is_okay(**locals(), type="drive")
    source = "https://drive.google.com/file/"
    source = source + "d/15kESeWR9wCWT7GW9VvChakTGin68iZsw/view"
    assert_block_attributes(block, source=source, caption="drive")
Beispiel #16
0
def test_link_to_collection_block(notion):
    block = notion.root_page.children.add_new(LinkToCollectionBlock)
    assert_block_is_okay(**locals(), type="link_to_collection")
Beispiel #17
0
def test_equation_block(notion):
    block = notion.root_page.children.add_new(EquationBlock)
    assert_block_is_okay(**locals(), type="equation")
    assert_block_attributes(block, title="E=mc^{2}", color="blue")
Beispiel #18
0
def test_figma_block(notion):
    block = notion.root_page.children.add_new(FigmaBlock)
    assert_block_is_okay(**locals(), type="figma")
Beispiel #19
0
def test_gist_block(notion):
    block = notion.root_page.children.add_new(GistBlock)
    assert_block_is_okay(**locals(), type="gist")
    source = "https://gist.github.com/arturtamborski/"
    source = source + "539a335fcd71f88bb8c05f316f54ba31"
    assert_block_attributes(block, source=source, caption="caption")
Beispiel #20
0
def test_collection_row_block(notion):
    block = notion.root_page.children.add_new(CollectionRowBlock)
    assert_block_is_okay(**locals(), type="page")
Beispiel #21
0
def test_loom_block(notion):
    block = notion.root_page.children.add_new(LoomBlock)
    assert_block_is_okay(**locals(), type="loom")
Beispiel #22
0
def test_invision_block(notion):
    block = notion.root_page.children.add_new(InvisionBlock)
    assert_block_is_okay(**locals(), type="invision")
Beispiel #23
0
def test_divider_block(notion):
    block = notion.root_page.children.add_new(DividerBlock)
    assert_block_is_okay(**locals(), type="divider")
Beispiel #24
0
def test_link_to_page_block(notion):
    block = notion.root_page.children.add_new(LinkToPageBlock)
    assert_block_is_okay(**locals(), type="link_to_page")
    assert_block_attributes(block, title="")
Beispiel #25
0
def test_factory_block(notion):
    block = notion.root_page.children.add_new(FactoryBlock)
    assert_block_is_okay(**locals(), type="factory")
    assert_block_attributes(block, title="factory", color="blue")
Beispiel #26
0
def test_quote_block(notion):
    block = notion.root_page.children.add_new(QuoteBlock)
    assert_block_is_okay(**locals(), type="quote")
    assert_block_attributes(block, title="quote", color="blue")
Beispiel #27
0
def test_pdf_block(notion):
    block = notion.root_page.children.add_new(PdfBlock)
    assert_block_is_okay(**locals(), type="pdf")
Beispiel #28
0
def test_sub_sub_header_block(notion):
    block = notion.root_page.children.add_new(SubSubHeaderBlock)
    assert_block_is_okay(**locals(), type="sub_sub_header")
    assert_block_attributes(block, title="subsubheader", color="blue")
Beispiel #29
0
def test_breadcrumb_block(notion):
    block = notion.root_page.children.add_new(BreadcrumbBlock)
    assert_block_is_okay(**locals(), type="breadcrumb")
Beispiel #30
0
def test_to_do_block(notion):
    block = notion.root_page.children.add_new(ToDoBlock)
    assert_block_is_okay(**locals(), type="to_do")
    assert_block_attributes(block, title="text", color="blue", checked=True)