Skip to content

Commit 5a7d776

Browse files
committed
test(my files): fix an instability
1 parent 765dd7f commit 5a7d776

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

QA/py/tests/test_my_files.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ def test_my_files(fastapi, caplog, tstlogs, title):
5757
assert list_rsp.status_code == 200
5858
my_files_root: Dict = list_rsp.json()
5959
assert my_files_root["path"] == ""
60-
assert len(my_files_root["entries"]) == 2
61-
assert my_files_root["entries"][0] == {
62-
"mtime": "",
63-
"name": DIRPATH,
64-
"size": 0,
65-
"type": "D",
66-
}
60+
my_files_root["entries"].sort(key=lambda x: x["name"])
61+
assert my_files_root["entries"] == [
62+
{
63+
"mtime": "",
64+
"name": DIRPATH,
65+
"size": 0,
66+
"type": "D",
67+
},
68+
{"mtime": "", "name": "import_test", "size": 0, "type": "D"},
69+
]
6770

6871
# The files are stored in the subdirectory
6972
DIRDEST = DIRPATH + SEPARATOR + DEST_DIR_NAME
@@ -73,7 +76,7 @@ def test_my_files(fastapi, caplog, tstlogs, title):
7376
assert my_files_subdir["path"] == DIRDEST
7477
assert (
7578
len(my_files_subdir["entries"]) == 1
76-
) # The second file being .txt will have 0 size on re-read
79+
) # The second file being .txt will have size 0 on re-read
7780
# test no longer valid as the zip is deleted after successful unzip
7881
# the_file = [fil for fil in my_files_subdir["entries"] if fil["size"] == 22654][0]
7982
# del the_file["mtime"] # Unpredictable
@@ -90,7 +93,7 @@ def test_my_files(fastapi, caplog, tstlogs, title):
9093
assert "FileNotFoundError" in "".join(errors)
9194

9295
# Import the file with the right path
93-
# The below (unfortunately) hard-coded path is valid on current configuration of EcoTaxa
96+
# The below (unfortunately) hard-coded path is valid on the current configuration of EcoTaxa
9497
file_path = "/tmp/ecotaxa_user.{}/{}/{}".format(
9598
CREATOR_USER_ID, # Should come from /api/users/me
9699
DIRPATH, # existing tag, created the on the first file creation with it

0 commit comments

Comments
 (0)