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

move check of path to only check name #4299

Merged
merged 3 commits into from
Nov 4, 2024
Merged
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
22 changes: 16 additions & 6 deletions tests/integration/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import asyncio
import time
from pathlib import Path
from typing import Generator

import pytest
Expand Down Expand Up @@ -205,11 +206,12 @@ async def get_file_data():

file_data = await AppHarness._poll_for_async(get_file_data)
assert isinstance(file_data, dict)
assert file_data[exp_name] == exp_contents
normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
assert normalized_file_data[Path(exp_name).name] == exp_contents

# check that the selected files are displayed
selected_files = driver.find_element(By.ID, f"selected_files{suffix}")
assert selected_files.text == exp_name
assert Path(selected_files.text).name == Path(exp_name).name

state = await upload_file.get_state(substate_token)
if secondary:
Expand Down Expand Up @@ -256,7 +258,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver):

# check that the selected files are displayed
selected_files = driver.find_element(By.ID, "selected_files")
assert selected_files.text == "\n".join(exp_files)
assert [Path(name).name for name in selected_files.text.split("\n")] == [
Path(name).name for name in exp_files
]

# do the upload
upload_button.click()
Expand All @@ -271,8 +275,9 @@ async def get_file_data():

file_data = await AppHarness._poll_for_async(get_file_data)
assert isinstance(file_data, dict)
normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
for exp_name, exp_contents in exp_files.items():
assert file_data[exp_name] == exp_contents
assert normalized_file_data[Path(exp_name).name] == exp_contents


@pytest.mark.parametrize("secondary", [False, True])
Expand Down Expand Up @@ -317,7 +322,9 @@ def test_clear_files(

# check that the selected files are displayed
selected_files = driver.find_element(By.ID, f"selected_files{suffix}")
assert selected_files.text == "\n".join(exp_files)
assert [Path(name).name for name in selected_files.text.split("\n")] == [
Path(name).name for name in exp_files
]

clear_button = driver.find_element(By.ID, f"clear_button{suffix}")
assert clear_button
Expand Down Expand Up @@ -369,6 +376,9 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive
# look up the backend state and assert on progress
state = await upload_file.get_state(substate_token)
assert state.substates[state_name].progress_dicts
assert exp_name not in state.substates[state_name]._file_data
file_data = state.substates[state_name]._file_data
assert isinstance(file_data, dict)
normalized_file_data = {Path(k).name: v for k, v in file_data.items()}
assert Path(exp_name).name not in normalized_file_data

target_file.unlink()
Loading