Beispiel #1
0
def block_update(notion_token, block_id):
    try:
        notion_api = NotionApi(notion_token)

        block = notion_api.block_update(block_id, request.json['text'])

        return jsonify(block_id=block.id), 200
    except Exception as error:
        return jsonify(error=str(error)), 500
Beispiel #2
0
def test_block_update(notion_token):
    notion_api = NotionApi(token=notion_token)
    test_page = get_test_page()

    block = test_page.children.add_new(TextBlock, title="test block update")
    updated_block = notion_api.block_update(block.id,
                                            "test block has been updated")

    assert updated_block.title == "test block has been updated"
    assert updated_block.id == block.id
Beispiel #3
0
def test_block_update_with_text_block(notion_token):
    notion_api = NotionApi(token=notion_token)
    test_page = get_test_page()

    block = test_page.children.add_new(TextBlock, title="test block update")
    updated_block = notion_api.block_update(
        block.id, {"title": "test block has been updated"})

    assert updated_block == {
        "id": block.id,
        "title": "test block has been updated"
    }
Beispiel #4
0
def test_block_update_with_collection_block(notion_token):
    notion_api = NotionApi(token=notion_token)

    collection_view = create_collection_view()
    block = collection_view.collection.add_row(name="test row",
                                               value=10,
                                               enabled=True)

    updated_block = notion_api.block_update(block.id, {
        "name": "test block has been updated",
        "value": 5
    })

    assert updated_block == {
        "id": block.id,
        "name": "test block has been updated",
        "value": 5,
        "category": None,
        "enabled": True,
        "tags": []
    }