Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sphinx 5.0 support #865

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
101 changes: 52 additions & 49 deletions tests/services/contents/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ async def test_get_text_file_contents(jp_fetch, contents, path, name):
)
assert expected_http_error(e, 400)


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled retrieving hidden files on Windows")
async def test_get_404_hidden(jp_fetch, contents, contents_dir):
# Create text files
hidden_dir = contents_dir / '.hidden'
hidden_dir = contents_dir / ".hidden"
hidden_dir.mkdir(parents=True, exist_ok=True)
txt = f"visible text file in hidden dir"
txtname = hidden_dir.joinpath(f"visible.txt")
Expand All @@ -242,7 +243,7 @@ async def test_get_404_hidden(jp_fetch, contents, contents_dir):
txt2 = f"hidden text file"
txtname2 = contents_dir.joinpath(f".hidden.txt")
txtname2.write_text(txt2, encoding="utf-8")

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand All @@ -261,6 +262,7 @@ async def test_get_404_hidden(jp_fetch, contents, contents_dir):
)
assert expected_http_error(e, 404)


@pytest.mark.parametrize("path,name", dirs)
async def test_get_binary_file_contents(jp_fetch, contents, path, name):
blobname = name + ".blob"
Expand Down Expand Up @@ -441,48 +443,38 @@ async def test_upload_txt(jp_fetch, contents, contents_dir, _check_created):
@pytest.mark.skipif(sys.platform == "win32", reason="Disabled uploading hidden files on Windows")
async def test_upload_txt_hidden(jp_fetch, contents, contents_dir):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
body = 'ünicode téxt'
body = "ünicode téxt"
model = {
'content' : body,
'format' : 'text',
'type' : 'file',
"content": body,
"format": "text",
"type": "file",
}
path = '.hidden/Upload tést.txt'
path = ".hidden/Upload tést.txt"
await jp_fetch("api", "contents", path, method="PUT", body=json.dumps(model))
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
body = 'ünicode téxt'
model = {
'content' : body,
'format' : 'text',
'type' : 'file',
'path': '.hidden/test.txt'
}
path = 'Upload tést.txt'
body = "ünicode téxt"
model = {"content": body, "format": "text", "type": "file", "path": ".hidden/test.txt"}
path = "Upload tést.txt"
await jp_fetch("api", "contents", path, method="PUT", body=json.dumps(model))
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
body = 'ünicode téxt'
body = "ünicode téxt"
model = {
'content' : body,
'format' : 'text',
'type' : 'file',
"content": body,
"format": "text",
"type": "file",
}
path = '.hidden.txt'
path = ".hidden.txt"
await jp_fetch("api", "contents", path, method="PUT", body=json.dumps(model))
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
body = 'ünicode téxt'
model = {
'content' : body,
'format' : 'text',
'type' : 'file',
'path': '.hidden.txt'
}
path = 'Upload tést.txt'
body = "ünicode téxt"
model = {"content": body, "format": "text", "type": "file", "path": ".hidden.txt"}
path = "Upload tést.txt"
await jp_fetch("api", "contents", path, method="PUT", body=json.dumps(model))
assert expected_http_error(e, 400)

Expand Down Expand Up @@ -581,7 +573,11 @@ async def test_copy_put_400(jp_fetch, contents, contents_dir, _check_created):


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled copying hidden files on Windows")
async def test_copy_put_400_hidden(jp_fetch, contents, contents_dir,):
async def test_copy_put_400_hidden(
jp_fetch,
contents,
contents_dir,
):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand All @@ -591,7 +587,7 @@ async def test_copy_put_400_hidden(jp_fetch, contents, contents_dir,):
body=json.dumps({"copy_from": "new.txt"}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand All @@ -601,7 +597,7 @@ async def test_copy_put_400_hidden(jp_fetch, contents, contents_dir,):
body=json.dumps({"copy_from": ".hidden/new.txt"}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand All @@ -611,7 +607,7 @@ async def test_copy_put_400_hidden(jp_fetch, contents, contents_dir,):
body=json.dumps({"copy_from": "new.txt"}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand All @@ -636,16 +632,20 @@ async def test_copy_dir_400(jp_fetch, contents, contents_dir, _check_created):


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled copying hidden files on Windows")
async def test_copy_400_hidden(jp_fetch, contents, contents_dir,):
async def test_copy_400_hidden(
jp_fetch,
contents,
contents_dir,
):

# Create text files
hidden_dir = contents_dir / '.hidden'
hidden_dir = contents_dir / ".hidden"
hidden_dir.mkdir(parents=True, exist_ok=True)
txt = f"visible text file in hidden dir"
txtname = hidden_dir.joinpath(f"new.txt")
txtname.write_text(txt, encoding="utf-8")

paths = ['new.txt', '.hidden.txt']
paths = ["new.txt", ".hidden.txt"]
for name in paths:
txt = f"{name} text file"
txtname = contents_dir.joinpath(f"{name}.txt")
Expand All @@ -660,7 +660,7 @@ async def test_copy_400_hidden(jp_fetch, contents, contents_dir,):
body=json.dumps({"copy_from": "new.txt"}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch(
"api",
Expand Down Expand Up @@ -689,7 +689,7 @@ async def test_copy_400_hidden(jp_fetch, contents, contents_dir,):
method="POST",
body=json.dumps({"copy_from": ".hidden.txt"}),
)
assert expected_http_error(e, 400)
assert expected_http_error(e, 400)


@pytest.mark.parametrize("path,name", dirs)
Expand Down Expand Up @@ -729,20 +729,22 @@ async def test_delete_non_empty_dir(jp_fetch, contents):
await jp_fetch("api", "contents", "å b", method="GET")
assert expected_http_error(e, 404)


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled deleting hidden dirs on Windows")
async def test_delete_hidden_dir(jp_fetch, contents):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch("api", "contents", ".hidden", method="DELETE")
assert expected_http_error(e, 400)


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled deleting hidden dirs on Windows")
async def test_delete_hidden_file(jp_fetch, contents):
#Test deleting file in a hidden directory
# Test deleting file in a hidden directory
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch("api", "contents", ".hidden/test.txt", method="DELETE")
assert expected_http_error(e, 400)

#Test deleting a hidden file
# Test deleting a hidden file
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch("api", "contents", ".hidden.txt", method="DELETE")
assert expected_http_error(e, 400)
Expand Down Expand Up @@ -778,11 +780,12 @@ async def test_rename(jp_fetch, jp_base_url, contents, contents_dir):
assert "z.ipynb" in nbnames
assert "a.ipynb" not in nbnames


@pytest.mark.skipif(sys.platform == "win32", reason="Disabled copying hidden files on Windows")
async def test_rename_400_hidden(jp_fetch, jp_base_url, contents, contents_dir):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
old_path = '.hidden/old.txt'
new_path = 'new.txt'
old_path = ".hidden/old.txt"
new_path = "new.txt"
# Rename the file
r = await jp_fetch(
"api",
Expand All @@ -792,10 +795,10 @@ async def test_rename_400_hidden(jp_fetch, jp_base_url, contents, contents_dir):
body=json.dumps({"path": new_path}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
old_path = 'old.txt'
new_path = '.hidden/new.txt'
old_path = "old.txt"
new_path = ".hidden/new.txt"
# Rename the file
r = await jp_fetch(
"api",
Expand All @@ -805,10 +808,10 @@ async def test_rename_400_hidden(jp_fetch, jp_base_url, contents, contents_dir):
body=json.dumps({"path": new_path}),
)
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
old_path = '.hidden.txt'
new_path = 'new.txt'
old_path = ".hidden.txt"
new_path = "new.txt"
# Rename the file
r = await jp_fetch(
"api",
Expand All @@ -820,8 +823,8 @@ async def test_rename_400_hidden(jp_fetch, jp_base_url, contents, contents_dir):
assert expected_http_error(e, 400)

with pytest.raises(tornado.httpclient.HTTPClientError) as e:
old_path = 'old.txt'
new_path = '.hidden.txt'
old_path = "old.txt"
new_path = ".hidden.txt"
# Rename the file
r = await jp_fetch(
"api",
Expand Down
Loading