Skip to content

Commit 4845220

Browse files
Merge pull request #1549 from VWS-Python/adamtheturtle/vws-web-tools-issue-1486
Return the target ID from upload_vumark_template
2 parents c7bc7db + 86d9292 commit 4845220

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

newsfragments/1486.change.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Make ``upload_vumark_template`` return the ID of the target it uploaded.
2+
It now waits for VWS to finish processing the target, which takes longer
3+
than waiting for the target to appear in the targets table.

src/vws_web_tools/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,14 @@ def upload_vumark_template(
610610
svg_file_path: Path,
611611
template_name: str,
612612
width: float,
613-
) -> None:
614-
"""Upload a VuMark SVG template to a VuMark database."""
613+
) -> str:
614+
"""Upload a VuMark SVG template to a VuMark database.
615+
616+
Returns:
617+
The ID of the uploaded target. Waiting for the ID means waiting
618+
for VWS to finish processing the target, which takes longer than
619+
waiting for the target to appear in the targets table.
620+
"""
615621
navigate_to_database(driver=driver, database_name=database_name)
616622

617623
thirty_second_wait = WebDriverWait(
@@ -687,6 +693,17 @@ def upload_vumark_template(
687693
),
688694
)
689695

696+
wait_for_vumark_target_link(
697+
driver=driver,
698+
database_name=database_name,
699+
target_name=template_name,
700+
)
701+
return get_vumark_target_id(
702+
driver=driver,
703+
database_name=database_name,
704+
target_name=template_name,
705+
)
706+
690707

691708
@beartype
692709
def _xpath_literal(

tests/test_create_database.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def test_upload_vumark_template(
376376
assert test_file_path is not None
377377
svg_path = test_file_path.parent / "fixtures" / "vumark_template.svg"
378378
template_name = f"template-{random_str}"
379-
vws_web_tools.upload_vumark_template(
379+
target_id = vws_web_tools.upload_vumark_template(
380380
driver=chrome_driver,
381381
database_name=database_name,
382382
svg_file_path=svg_path,
@@ -385,6 +385,9 @@ def test_upload_vumark_template(
385385
)
386386

387387
assert template_name in chrome_driver.page_source
388+
expected_target_id_length = 32
389+
assert len(target_id) == expected_target_id_length
390+
assert target_id.isalnum()
388391

389392

390393
def test_upload_vumark_template_cli(

0 commit comments

Comments
 (0)