def test_overwrite_file_for_multiple_runs():
    preprocessor = ConvertNotebookPreprocessor(notebook_file=NOTEBOOK_PATH)
    files = preprocessor.preprocess()
    files_overwrite = preprocessor.preprocess()
    converted_notebook_path = posixpath.join(
        os.path.dirname(NOTEBOOK_PATH),
        os.path.basename(preprocessor.executable))
    os.remove(converted_notebook_path)
    assert files == files_overwrite
def test_get_command():
    preprocessor = ConvertNotebookPreprocessor(notebook_file=NOTEBOOK_PATH)
    preprocessor.preprocess()
    command = preprocessor.get_command()
    converted_notebook_path = posixpath.join(
        os.path.dirname(NOTEBOOK_PATH),
        os.path.basename(preprocessor.executable))
    conv_notebook_context_path = posixpath.join(DEFAULT_DEST_PREFIX,
                                                converted_notebook_path)
    expected_command = 'python {}'.format(conv_notebook_context_path)
    os.remove(converted_notebook_path)
    assert command == expected_command.split()
def test_preprocess():
    preprocessor = ConvertNotebookPreprocessor(notebook_file=NOTEBOOK_PATH)
    files = preprocessor.preprocess()
    converted_notebook_path = posixpath.join(
        os.path.dirname(NOTEBOOK_PATH),
        os.path.basename(preprocessor.executable))
    os.remove(converted_notebook_path)
    assert Path(converted_notebook_path) in files