@@ -23,7 +23,7 @@ def jp_contents_manager(request, tmp_path):
23
23
24
24
25
25
@pytest .fixture (params = [FileContentsManager , AsyncFileContentsManager ])
26
- def file_contents_manager_class (request , tmp_path ):
26
+ def jp_file_contents_manager_class (request , tmp_path ):
27
27
return request .param
28
28
29
29
# -------------- Functions ----------------------------
@@ -100,46 +100,45 @@ async def check_populated_dir_files(jp_contents_manager, api_path):
100
100
# ----------------- Tests ----------------------------------
101
101
102
102
103
- def test_root_dir (file_contents_manager_class , tmp_path ):
104
- fm = file_contents_manager_class (root_dir = str (tmp_path ))
103
+ def test_root_dir (jp_file_contents_manager_class , tmp_path ):
104
+ fm = jp_file_contents_manager_class (root_dir = str (tmp_path ))
105
105
assert fm .root_dir == str (tmp_path )
106
106
107
107
108
- def test_missing_root_dir (file_contents_manager_class , tmp_path ):
108
+ def test_missing_root_dir (jp_file_contents_manager_class , tmp_path ):
109
109
root = tmp_path / 'notebook' / 'dir' / 'is' / 'missing'
110
110
with pytest .raises (TraitError ):
111
- file_contents_manager_class (root_dir = str (root ))
111
+ jp_file_contents_manager_class (root_dir = str (root ))
112
112
113
113
114
- def test_invalid_root_dir (file_contents_manager_class , tmp_path ):
114
+ def test_invalid_root_dir (jp_file_contents_manager_class , tmp_path ):
115
115
temp_file = tmp_path / 'file.txt'
116
116
temp_file .write_text ('' )
117
117
with pytest .raises (TraitError ):
118
- file_contents_manager_class (root_dir = str (temp_file ))
118
+ jp_file_contents_manager_class (root_dir = str (temp_file ))
119
119
120
-
121
- def test_get_os_path (file_contents_manager_class , tmp_path ):
122
- fm = file_contents_manager_class (root_dir = str (tmp_path ))
120
+ def test_get_os_path (jp_file_contents_manager_class , tmp_path ):
121
+ fm = jp_file_contents_manager_class (root_dir = str (tmp_path ))
123
122
path = fm ._get_os_path ('/path/to/notebook/test.ipynb' )
124
123
rel_path_list = '/path/to/notebook/test.ipynb' .split ('/' )
125
124
fs_path = os .path .join (fm .root_dir , * rel_path_list )
126
125
assert path == fs_path
127
126
128
- fm = file_contents_manager_class (root_dir = str (tmp_path ))
127
+ fm = jp_file_contents_manager_class (root_dir = str (tmp_path ))
129
128
path = fm ._get_os_path ('test.ipynb' )
130
129
fs_path = os .path .join (fm .root_dir , 'test.ipynb' )
131
130
assert path == fs_path
132
131
133
- fm = file_contents_manager_class (root_dir = str (tmp_path ))
132
+ fm = jp_file_contents_manager_class (root_dir = str (tmp_path ))
134
133
path = fm ._get_os_path ('////test.ipynb' )
135
134
fs_path = os .path .join (fm .root_dir , 'test.ipynb' )
136
135
assert path == fs_path
137
136
138
137
139
- def test_checkpoint_subdir (file_contents_manager_class , tmp_path ):
138
+ def test_checkpoint_subdir (jp_file_contents_manager_class , tmp_path ):
140
139
subd = 'sub ∂ir'
141
140
cp_name = 'test-cp.ipynb'
142
- fm = file_contents_manager_class (root_dir = str (tmp_path ))
141
+ fm = jp_file_contents_manager_class (root_dir = str (tmp_path ))
143
142
tmp_path .joinpath (subd ).mkdir ()
144
143
cpm = fm .checkpoints
145
144
cp_dir = cpm .checkpoint_path ('cp' , 'test.ipynb' )
@@ -148,10 +147,10 @@ def test_checkpoint_subdir(file_contents_manager_class, tmp_path):
148
147
assert cp_dir == os .path .join (str (tmp_path ), cpm .checkpoint_dir , cp_name )
149
148
150
149
151
- async def test_bad_symlink (file_contents_manager_class , tmp_path ):
150
+ async def test_bad_symlink (jp_file_contents_manager_class , tmp_path ):
152
151
td = str (tmp_path )
153
152
154
- cm = file_contents_manager_class (root_dir = td )
153
+ cm = jp_file_contents_manager_class (root_dir = td )
155
154
path = 'test bad symlink'
156
155
_make_dir (cm , path )
157
156
@@ -173,10 +172,10 @@ async def test_bad_symlink(file_contents_manager_class, tmp_path):
173
172
sys .platform .startswith ('win' ),
174
173
reason = "Windows doesn't detect symlink loops"
175
174
)
176
- async def test_recursive_symlink (file_contents_manager_class , tmp_path ):
175
+ async def test_recursive_symlink (jp_file_contents_manager_class , tmp_path ):
177
176
td = str (tmp_path )
178
177
179
- cm = file_contents_manager_class (root_dir = td )
178
+ cm = jp_file_contents_manager_class (root_dir = td )
180
179
path = 'test recursive symlink'
181
180
_make_dir (cm , path )
182
181
@@ -195,9 +194,9 @@ async def test_recursive_symlink(file_contents_manager_class, tmp_path):
195
194
assert 'recursive' not in contents
196
195
197
196
198
- async def test_good_symlink (file_contents_manager_class , tmp_path ):
197
+ async def test_good_symlink (jp_file_contents_manager_class , tmp_path ):
199
198
td = str (tmp_path )
200
- cm = file_contents_manager_class (root_dir = td )
199
+ cm = jp_file_contents_manager_class (root_dir = td )
201
200
parent = 'test good symlink'
202
201
name = 'good symlink'
203
202
path = '{0}/{1}' .format (parent , name )
@@ -216,13 +215,13 @@ async def test_good_symlink(file_contents_manager_class, tmp_path):
216
215
sys .platform .startswith ('win' ),
217
216
reason = "Can't test permissions on Windows"
218
217
)
219
- async def test_403 (file_contents_manager_class , tmp_path ):
218
+ async def test_403 (jp_file_contents_manager_class , tmp_path ):
220
219
if hasattr (os , 'getuid' ):
221
220
if os .getuid () == 0 :
222
221
raise pytest .skip ("Can't test permissions as root" )
223
222
224
223
td = str (tmp_path )
225
- cm = file_contents_manager_class (root_dir = td )
224
+ cm = jp_file_contents_manager_class (root_dir = td )
226
225
model = await ensure_async (cm .new_untitled (type = 'file' ))
227
226
os_path = cm ._get_os_path (model ['path' ])
228
227
@@ -233,10 +232,9 @@ async def test_403(file_contents_manager_class, tmp_path):
233
232
except HTTPError as e :
234
233
assert e .status_code == 403
235
234
236
-
237
- async def test_escape_root (file_contents_manager_class , tmp_path ):
235
+ async def test_escape_root (jp_file_contents_manager_class , tmp_path ):
238
236
td = str (tmp_path )
239
- cm = file_contents_manager_class (root_dir = td )
237
+ cm = jp_file_contents_manager_class (root_dir = td )
240
238
# make foo, bar next to root
241
239
with open (os .path .join (cm .root_dir , '..' , 'foo' ), 'w' ) as f :
242
240
f .write ('foo' )
0 commit comments