@@ -54,6 +54,11 @@ def contents_dir(tmp_path, jp_serverapp):
54
54
@pytest .fixture
55
55
def contents (contents_dir ):
56
56
# Create files in temporary directory
57
+ paths = {
58
+ 'notebooks' : [],
59
+ 'textfiles' : [],
60
+ 'blobs' : [],
61
+ }
57
62
for d , name in dirs :
58
63
p = contents_dir / d
59
64
p .mkdir (parents = True , exist_ok = True )
@@ -62,16 +67,21 @@ def contents(contents_dir):
62
67
nb = writes (new_notebook (), version = 4 )
63
68
nbname = p .joinpath ('{}.ipynb' .format (name ))
64
69
nbname .write_text (nb , encoding = 'utf-8' )
70
+ paths ['notebooks' ].append (nbname .relative_to (contents_dir ))
65
71
66
72
# Create a text file
67
73
txt = '{} text file' .format (name )
68
74
txtname = p .joinpath ('{}.txt' .format (name ))
69
75
txtname .write_text (txt , encoding = 'utf-8' )
76
+ paths ['textfiles' ].append (txtname .relative_to (contents_dir ))
70
77
71
78
# Create a random blob
72
79
blob = name .encode ('utf-8' ) + b'\xFF '
73
80
blobname = p .joinpath ('{}.blob' .format (name ))
74
81
blobname .write_bytes (blob )
82
+ paths ['blobs' ].append (blobname .relative_to (contents_dir ))
83
+ paths ['all' ] = list (paths .values ())
84
+ return paths
75
85
76
86
77
87
@pytest .fixture
@@ -845,3 +855,14 @@ async def test_file_checkpoints(jp_fetch, contents):
845
855
)
846
856
cps = json .loads (r .body .decode ())
847
857
assert cps == []
858
+
859
+
860
+ async def test_trust (jp_fetch , contents ):
861
+ # It should be able to trust a notebook that exists
862
+ for path in contents ['notebooks' ]:
863
+ r = await jp_fetch (
864
+ 'api' , 'contents' , str (path ), 'trust' ,
865
+ method = 'POST' ,
866
+ allow_nonstandard_methods = True
867
+ )
868
+ assert r .code == 201
0 commit comments