Skip to content

Commit f19425c

Browse files
committed
fix: ignore order when comparing the files in a directory in tests
1 parent 03d80f0 commit f19425c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

reana_jupyterlab/tests/test_files.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,30 @@ def filespace():
4141
shutil.rmtree(base_path)
4242

4343
@pytest.mark.parametrize('path, expected', [
44-
('pytest_workspace', {'entries': [{ 'name': 'file6.yaml', 'type': 'file', 'path': 'pytest_workspace/file6.yaml'}, {'name': 'folder1', 'type': 'directory', 'path': 'pytest_workspace/folder1'}]}),
45-
('pytest_workspace/folder1', {'entries': [{'name': 'folder2', 'type': 'directory', 'path': 'pytest_workspace/folder1/folder2'}]}),
46-
('pytest_workspace/folder1/folder2', {'entries': [{'name': 'file3.yaml', 'type': 'file', 'path': 'pytest_workspace/folder1/folder2/file3.yaml'}, {'name': 'folder3', 'type': 'directory', 'path': 'pytest_workspace/folder1/folder2/folder3'}]}),
47-
('pytest_workspace/folder1/folder2/folder3', {'entries': []}),
48-
('pytest_workspace/folder4', ''),
49-
('pytest_workspace/file4.java', ''),
50-
('pytest_workspace/folder1/../file6.yaml', '')
44+
('pytest_workspace', set([('folder1', 'directory', 'pytest_workspace/folder1'), ('file6.yaml', 'file', 'pytest_workspace/file6.yaml')])),
45+
('pytest_workspace/folder1', set([('folder2', 'directory', 'pytest_workspace/folder1/folder2')])),
46+
('pytest_workspace/folder1/folder2', set([('file3.yaml', 'file', 'pytest_workspace/folder1/folder2/file3.yaml'), ('folder3', 'directory', 'pytest_workspace/folder1/folder2/folder3')])),
47+
('pytest_workspace/folder1/folder2/folder3', set()),
48+
('pytest_workspace/folder4', set()),
49+
('pytest_workspace/file4.java', set()),
50+
('pytest_workspace/folder1/../file6.yaml', set())
5151
])
5252
async def test_get_files(jp_fetch, path, expected, filespace):
5353
try:
5454
response = await jp_fetch(ENDPOINT, params={'path': path})
5555
assert response.code == 200
56+
5657
data = json.loads(response.body)
57-
assert data == expected
58+
59+
assert 'entries' in data
60+
entries = data['entries']
61+
62+
assert isinstance(entries, list)
63+
64+
received = set((entry['name'], entry['type'], entry['path']) for entry in entries)
65+
assert received == expected
66+
67+
5868
except Exception as e:
69+
print(e)
5970
assert e.code == 404

0 commit comments

Comments
 (0)