Skip to content

Commit

Permalink
put test files in the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Dec 9, 2024
1 parent 8b4af54 commit 6874ba6
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,10 @@ async def test_bulk_specification_success():
async def test_bulk_specification_dts_success():
async with AppClient(config) as cli:
with FileUtil() as fu:
fu.make_dir("testuser/dts_folder") # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser"
sub_dir = "dts_folder"
dts_dir = f"testuser/{sub_dir}"
fu.make_dir(dts_dir) # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser" / sub_dir
manifest_1 = "test_manifest_1.json"
manifest_1_dict = {
"resources": [],
Expand Down Expand Up @@ -1108,20 +1110,20 @@ async def test_bulk_specification_dts_success():
json.dump(manifest_1_dict, f)
with open(base / manifest_2, "w", encoding="utf-8") as f:
json.dump(manifest_2_dict, f)
resp = await cli.get(f"bulk_specification/?files={manifest_1} , {manifest_2}&dts")
resp = await cli.get(f"bulk_specification/?files={sub_dir}/{manifest_1} , {sub_dir}/{manifest_2}&dts")
jsn = await resp.json()
# fails for now. will update when schema/parser is properly finished.
assert jsn == {
"errors": [
{
"type": "cannot_parse_file",
"file": f"testuser/{manifest_1}",
"file": f"{dts_dir}/{manifest_1}",
"message": "No import specification data in file",
"tab": None,
},
{
"type": "cannot_parse_file",
"file": f"testuser/{manifest_2}",
"file": f"{dts_dir}/{manifest_2}",
"message": "No import specification data in file",
"tab": None,
},
Expand Down Expand Up @@ -1150,8 +1152,10 @@ async def test_bulk_specification_dts_success():
async def test_bulk_specification_dts_fail_json_without_dts():
async with AppClient(config) as cli:
with FileUtil() as fu:
fu.make_dir("testuser/dts_folder") # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser"
sub_dir = "dts_folder"
dts_dir = f"testuser/{sub_dir}"
fu.make_dir(dts_dir) # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser" / sub_dir
manifest_1 = "test_manifest_1.json"
manifest_1_dict = {
"resources": [],
Expand All @@ -1171,13 +1175,13 @@ async def test_bulk_specification_dts_fail_json_without_dts():
}
with open(base / manifest_1, "w", encoding="utf-8") as f:
json.dump(manifest_1_dict, f)
resp = await cli.get(f"bulk_specification/?files={manifest_1}")
resp = await cli.get(f"bulk_specification/?files={sub_dir}/{manifest_1}")
jsn = await resp.json()
assert jsn == {
"errors": [
{
"type": "cannot_parse_file",
"file": f"testuser/{manifest_1}",
"file": f"{dts_dir}/{manifest_1}",
"message": "json is not a supported file type for import specifications",
"tab": None,
}
Expand All @@ -1189,19 +1193,21 @@ async def test_bulk_specification_dts_fail_json_without_dts():
async def test_bulk_specification_dts_fail_wrong_format():
async with AppClient(config) as cli:
with FileUtil() as fu:
fu.make_dir("testuser/dts_folder") # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser"
sub_dir = "dts_folder"
dts_dir = f"testuser/{sub_dir}"
fu.make_dir(dts_dir) # testuser is hardcoded in the auth mock
base = Path(fu.base_dir) / "testuser" / sub_dir
manifest = "test_manifest.json"
manifest_data = ["wrong", "format"]
with open(base / manifest, "w", encoding="utf-8") as f:
json.dump(manifest_data, f)
resp = await cli.get(f"bulk_specification/?files={manifest}&dts")
resp = await cli.get(f"bulk_specification/?files={sub_dir}/{manifest}&dts")
jsn = await resp.json()
assert jsn == {
"errors": [
{
"type": "cannot_parse_file",
"file": f"testuser/{manifest}",
"file": f"{dts_dir}/{manifest}",
"message": "Manifest is not a dictionary",
"tab": None,
}
Expand Down

0 comments on commit 6874ba6

Please sign in to comment.