コード例 #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_notebook_list(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)
            n = {'name':filepath, 'notebook_id':notebook_id}

            correct = []
            correct.append(n)

            nlist = km.list_notebooks()
            assert nlist[0]['name'] == correct[0]['name']
            assert nlist[0]['notebook_id'] == correct[0]['notebook_id']
コード例 #3
0
ファイル: test_cli.py プロジェクト: dalejung/ipycli
    def test_existing_notebook(self):
        # Create a dir with notebooks
        td = TemporaryDirectory()
        ndir = td.__enter__()
        km = NotebookManager(notebook_dir=ndir)
        filename = 'new_test.ipynb'
        filepath = os.path.join(ndir, filename)
        notebook_id = km.new_notebook(ndir=ndir, name=filename)


        td2 = TemporaryDirectory()
        ndir2 = td2.__enter__()
        nbm = NotebookManager(notebook_dir=ndir2)

        assert nbm.notebook_dir != km.notebook_dir
        assert filepath not in nbm.path_mapping.values()
        assert filepath not in nbm.pathed_notebooks.values()
        nbm.get_pathed_notebook(filepath)
        assert nbm.path_mapping.values()[0] == filepath
        assert filepath in nbm.pathed_notebooks.values()
コード例 #4
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)