Skip to content

Commit 6c8501d

Browse files
committed
add unittest for voila extra files
1 parent 3d137ce commit 6c8501d

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

tests/test_bundle.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ def test_is_not_executable(self):
814814
bqplot_ipynb = os.path.join(bqplot_dir, "bqplot.ipynb")
815815
dashboard_dir = os.path.join(cur_dir, "./testdata/voila/dashboard/")
816816
dashboard_ipynb = os.path.join(dashboard_dir, "dashboard.ipynb")
817+
dashboard_extra_ipynb = os.path.join(dashboard_dir, "bqplot.ipynb")
817818
multivoila_dir = os.path.join(cur_dir, "./testdata/voila/multi-voila/")
818819
nonexistent_dir = os.path.join(cur_dir, "./testdata/nonexistent/")
819820
nonexistent_file = os.path.join(cur_dir, "nonexistent.txt")
@@ -985,6 +986,46 @@ def test_create_voila_manifest_2(path, entrypoint):
985986
assert ans == json.loads(manifest.flattened_copy.json)
986987

987988

989+
def test_create_voila_manifest_extra():
990+
environment = Environment(
991+
conda=None,
992+
contents="numpy\nipywidgets\nbqplot\n",
993+
error=None,
994+
filename="requirements.txt",
995+
locale="en_US.UTF-8",
996+
package_manager="pip",
997+
pip="23.0.1",
998+
python="3.8.12",
999+
source="file",
1000+
)
1001+
ans = {
1002+
"version": 1,
1003+
"locale": "en_US.UTF-8",
1004+
"metadata": {"appmode": "jupyter-voila", "entrypoint": "dashboard.ipynb"},
1005+
"python": {
1006+
"version": "3.8.12",
1007+
"package_manager": {"name": "pip", "version": "23.0.1", "package_file": "requirements.txt"},
1008+
},
1009+
"files": {
1010+
"requirements.txt": {"checksum": "d51994456975ff487749acc247ae6d63"},
1011+
"bqplot.ipynb": {"checksum": "79f8622228eded646a3038848de5ffd9"},
1012+
"dashboard.ipynb": {"checksum": "6b42a0730d61e5344a3e734f5bbeec25"},
1013+
},
1014+
}
1015+
manifest = create_voila_manifest(
1016+
dashboard_ipynb,
1017+
None,
1018+
environment,
1019+
app_mode=AppModes.JUPYTER_VOILA,
1020+
extra_files=[dashboard_extra_ipynb],
1021+
excludes=None,
1022+
force_generate=True,
1023+
image=None,
1024+
multi_notebook=False,
1025+
)
1026+
assert ans == json.loads(manifest.flattened_copy.json)
1027+
1028+
9881029
@pytest.mark.parametrize(
9891030
(
9901031
"path",
@@ -1353,6 +1394,54 @@ def test_make_voila_bundle_2(
13531394
assert ans == json.loads(tar.extractfile("manifest.json").read().decode("utf-8"))
13541395

13551396

1397+
def test_make_voila_bundle_extra():
1398+
environment = Environment(
1399+
conda=None,
1400+
contents="numpy\nipywidgets\nbqplot\n",
1401+
error=None,
1402+
filename="requirements.txt",
1403+
locale="en_US.UTF-8",
1404+
package_manager="pip",
1405+
pip="23.0.1",
1406+
python="3.8.12",
1407+
source="file",
1408+
)
1409+
ans = {
1410+
"version": 1,
1411+
"locale": "en_US.UTF-8",
1412+
"metadata": {"appmode": "jupyter-voila", "entrypoint": "dashboard.ipynb"},
1413+
"python": {
1414+
"version": "3.8.12",
1415+
"package_manager": {"name": "pip", "version": "23.0.1", "package_file": "requirements.txt"},
1416+
},
1417+
"files": {
1418+
"requirements.txt": {"checksum": "d51994456975ff487749acc247ae6d63"},
1419+
"bqplot.ipynb": {"checksum": "79f8622228eded646a3038848de5ffd9"},
1420+
"dashboard.ipynb": {"checksum": "6b42a0730d61e5344a3e734f5bbeec25"},
1421+
},
1422+
}
1423+
with make_voila_bundle(
1424+
dashboard_ipynb,
1425+
None,
1426+
extra_files=[dashboard_extra_ipynb],
1427+
excludes=None,
1428+
force_generate=True,
1429+
environment=environment,
1430+
image=None,
1431+
multi_notebook=False,
1432+
) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar:
1433+
names = sorted(tar.getnames())
1434+
assert names == [
1435+
"bqplot.ipynb",
1436+
"dashboard.ipynb",
1437+
"manifest.json",
1438+
"requirements.txt",
1439+
]
1440+
reqs = tar.extractfile("requirements.txt").read()
1441+
assert reqs == b"numpy\nipywidgets\nbqplot\n"
1442+
assert ans == json.loads(tar.extractfile("manifest.json").read().decode("utf-8"))
1443+
1444+
13561445
single_file_index_dir = os.path.join(cur_dir, "./testdata/html_tests/single_file_index")
13571446
single_file_index_file = os.path.join(cur_dir, "./testdata/html_tests/single_file_index/index.html")
13581447
single_file_nonindex_dir = os.path.join(cur_dir, "./testdata/html_tests/single_file_nonindex")

0 commit comments

Comments
 (0)