File: test_workspaces_app.py

package info (click to toggle)
jupyterlab-server 2.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 692 kB
  • sloc: python: 3,532; makefile: 13; sh: 2
file content (71 lines) | stat: -rw-r--r-- 2,075 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import json
import os
import sys

from jupyterlab_server.workspaces_app import (
    WorkspaceExportApp,
    WorkspaceImportApp,
    WorkspaceListApp,
)


def test_workspace_apps(jp_environ, tmp_path):
    sys.argv = [sys.argv[0]]

    data = {
        "data": {
            "layout-restorer:data": {
                "main": {
                    "dock": {
                        "type": "tab-area",
                        "currentIndex": 1,
                        "widgets": ["notebook:Untitled1.ipynb"],
                    },
                    "current": "notebook:Untitled1.ipynb",
                },
                "down": {"size": 0, "widgets": []},
                "left": {
                    "collapsed": False,
                    "current": "filebrowser",
                    "widgets": [
                        "filebrowser",
                        "running-sessions",
                        "@jupyterlab/toc:plugin",
                        "extensionmanager.main-view",
                    ],
                },
                "right": {
                    "collapsed": True,
                    "widgets": ["jp-property-inspector", "debugger-sidebar"],
                },
                "relativeSizes": [0.17370242214532872, 0.8262975778546713, 0],
            },
            "notebook:Untitled1.ipynb": {
                "data": {"path": "Untitled1.ipynb", "factory": "Notebook"}
            },
        },
        "metadata": {"id": "default"},
    }

    data_file = os.path.join(tmp_path, "test.json")
    with open(data_file, "w") as fid:
        json.dump(data, fid)

    app = WorkspaceImportApp(workspaces_dir=str(tmp_path))
    app.initialize()
    app.extra_args = [data_file]
    app.start()

    app1 = WorkspaceExportApp(workspaces_dir=str(tmp_path))
    app1.initialize()
    app1.start()

    app2 = WorkspaceListApp(workspaces_dir=str(tmp_path))
    app2.initialize()
    app2.start()

    app2.jsonlines = True
    app2.start()