コード例 #1
0
ファイル: test_cli.py プロジェクト: dalejung/ipycli
    def test_new_notebook(self):
        with TemporaryDirectory() as td:
            km = NotebookManager(notebook_dir=td)
            filename = 'Untitled0.ipynb'
            filepath = os.path.join(td, filename)
            notebook_id = km.new_notebook(ndir=td)
            assert os.path.isfile(filepath)

            # Now make sure path mapping works
            assert km.path_mapping[notebook_id] == filepath
            assert km.find_path(notebook_id) == filepath
コード例 #2
0
ファイル: test_cli.py プロジェクト: dalejung/ipycli
    def test_delete_notebook(self):
        with TemporaryDirectory() as td:
            km = NotebookManager(notebook_dir=td)
            filename = 'new_test.ipynb'
            filepath = os.path.join(td, filename)
            notebook_id = km.new_notebook(ndir=td, name=filename)
            assert os.path.isfile(filepath)

            # Now make sure path mapping works
            assert km.path_mapping[notebook_id] == filepath
            assert km.find_path(notebook_id) == filepath

            assert notebook_id in km.mapping
            assert notebook_id in km.path_mapping
            assert notebook_id in km.rev_mapping.values()
            km.delete_notebook(notebook_id)
            assert notebook_id not in km.mapping
            assert notebook_id not in km.path_mapping
            assert notebook_id not in km.rev_mapping.values()
            assert not os.path.isfile(filepath)