Beispiel #1
0
def test_cli_append(mockClient, upload):
    '''should append when using that flag'''
    #act
    cli(['token_v2', 'page_url', 'tests/TEST.md', '--append'])

    #assert
    #Should've been called with a file and the passed block
    args0, kwargs0 = upload.call_args
    assert isinstance(args0[0], IOBase)
    assert args0[0].name == 'tests/TEST.md'
    assert args0[1] == mockClient.get_block.return_value
Beispiel #2
0
def test_cli_html_img_tag(mockClient, upload):
    '''should enable the extension'''

    #act
    cli(['token_v2', 'page_url', 'tests/TEST.md', '--append', '--html-img'])

    #assert
    args0, kwargs0 = upload.call_args
    renderer = args0[3]()
    assert "HTMLSpan" in renderer.render_map
    assert "HTMLBlock" in renderer.render_map
Beispiel #3
0
def test_cli_create_single_page(mockClient, upload):
    '''should create a single page'''
    #act
    cli(['token_v2', 'page_url', 'tests/TEST.md'])

    #assert
    #Should've been called with a file and the passed block
    args0, kwargs0 = upload.call_args
    assert isinstance(args0[0], IOBase)
    assert args0[0].name == 'tests/TEST.md'
    assert args0[1] == mockClient.get_block.return_value.children[0]
    assert args0[1].title == 'TEST.md'
Beispiel #4
0
def test_cli_create_multiple_pages(mockClient, upload):
    '''should create multiple pages'''
    #act
    cli(['token_v2', 'page_url', 'tests/TEST.md', 'tests/COMPREHENSIVE_TEST.md'])
    args0, kwargs0 = upload.call_args_list[0]
    assert isinstance(args0[0], IOBase)
    assert args0[0].name == 'tests/TEST.md'
    assert args0[1] == mockClient.get_block.return_value.children[0]
    assert args0[1].title == 'TEST.md'
    args1, kwargs1 = upload.call_args_list[1]
    assert isinstance(args1[0], IOBase)
    assert args1[0].name == 'tests/COMPREHENSIVE_TEST.md'
    assert args1[1] == mockClient.get_block.return_value.children[1]
    assert args1[1].title == 'COMPREHENSIVE_TEST.md'
Beispiel #5
0
def test_cli_clear_previous(mockClient, upload):
    '''should clear previously title pages with the same name when passed that flag'''
    #arrange
    testNoBlock = mockClient.get_block().children.add_new(PageBlock, title='NO_TEST.md')
    testBlock = mockClient.get_block().children.add_new(PageBlock, title='TEST.md')

    #act
    cli(['token_v2', 'page_url', 'tests/TEST.md', '--clear-previous'])

    #assert
    testNoBlock.remove.assert_not_called()
    testBlock.remove.assert_called_with()
    args0, kwargs0 = upload.call_args
    assert isinstance(args0[0], IOBase)
    assert args0[0].name == 'tests/TEST.md'
    assert args0[1] == mockClient.get_block.return_value.children[1]
    assert args0[1].title == 'TEST.md'
Beispiel #6
0
def test_cli_no_arguments(mockClient):
    '''should error when nothing is passed'''
    #act/assert
    with pytest.raises(SystemExit):
        cli([])