Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async def test_download_list_manifest_with_custom_csv_descriptor(
path=path,
name=file_name,
)
await file.store_async(synapse_client=syn)
file = await file.store_async(synapse_client=syn)
schedule_for_cleanup(file.id)
await _add_to_cart(file, syn, scheduled_for_cart_removal)

Expand All @@ -582,29 +582,37 @@ async def test_download_list_manifest_with_custom_csv_descriptor(
assert "\t" in content, "Expected tab separators in manifest"

# AND the escape character was used for the embedded quote in the file name
assert "/'" in content, (
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about this more, this maybe a server side error. If Per the Synapse docs, escapeCharacter is "for escaping a separator or quote". So the spec says it should produce:'it/'s_test.csv' when the file name is: 'it's_test.csv'

f"Expected escape sequence /' in manifest (from escaping ' in file name), "
assert "/" in content, (
f"Expected escape sequence /' in manifest, " f"got: {content!r}"
)

# AND the embedded quote in the file name was escaped by doubling
assert "''" in content, (
f"Expected doubled quote '' in manifest (from escaping ' in file name), "
f"got: {content!r}"
)

# AND line endings are LF only (no CR)
assert "\r" not in content, "Expected LF-only line endings; found CR"

# AND there is no header row -- the first non-empty line is the data row
# NOTE: The cart is per-user and shared across all parallel workers (-n 8).
# Other tests running concurrently can add items to the cart, so the manifest
# may contain more than just this test's file.
lines = [line for line in content.split("\n") if line]
assert lines, "Expected at least one row in the manifest"
assert file.id in lines[0], (
f"Expected first line to be the data row containing {file.id} "
f"(no header), got: {lines[0]!r}"
assert any(file.id in line for line in lines), (
f"Expected a data row containing {file.id} in manifest, "
f"got: {content!r}"
)

# AND the name field is wrapped in single quotes (the writer quoted it
# because it contains the quote character)
fields = lines[0].split("\t")
# because it contains the quote character).
# Search all lines since the cart may contain other items from concurrent tests.
file_line = next((line for line in lines if file.id in line), None)
assert file_line is not None, f"No line found for {file.id} in manifest"
fields = file_line.split("\t")
name_field = next((f for f in fields if uuid_suffix in f), None)
assert (
name_field is not None
), f"Name field containing {uuid_suffix!r} not found in {lines[0]!r}"
assert name_field.startswith("'") and name_field.endswith(
"'"
), f"Expected name field wrapped in single quotes, got: {name_field!r}"
), f"Name field containing {uuid_suffix!r} not found in {file_line!r}"
Loading