Skip to content

Commit 320a02f

Browse files
adamtheturtleclaude
andcommitted
Parametrize format tests in test_vumark
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 6797d9a commit 320a02f

1 file changed

Lines changed: 15 additions & 95 deletions

File tree

tests/test_vumark.py

Lines changed: 15 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,101 +16,23 @@ class TestGenerateVuMark:
1616
"""Tests for ``vws generate-vumark``."""
1717

1818
@staticmethod
19-
def test_generate_vumark_png(
20-
mock_database: VuforiaDatabase,
21-
vws_client: VWS,
22-
high_quality_image: io.BytesIO,
23-
tmp_path: Path,
24-
) -> None:
25-
"""It is possible to generate a VuMark as PNG."""
26-
runner = CliRunner()
27-
target_id = vws_client.add_target(
28-
name=uuid.uuid4().hex,
29-
width=1,
30-
image=high_quality_image,
31-
active_flag=True,
32-
application_metadata=None,
33-
)
34-
vws_client.wait_for_target_processed(target_id=target_id)
35-
output_file = tmp_path / "output.png"
36-
commands = [
37-
"generate-vumark",
38-
"--target-id",
39-
target_id,
40-
"--instance-id",
41-
"12345",
42-
"--format",
43-
"png",
44-
"--output",
45-
str(object=output_file),
46-
"--server-access-key",
47-
mock_database.server_access_key,
48-
"--server-secret-key",
49-
mock_database.server_secret_key,
50-
]
51-
result = runner.invoke(
52-
cli=vws_group,
53-
args=commands,
54-
catch_exceptions=False,
55-
color=True,
56-
)
57-
assert result.exit_code == 0
58-
assert output_file.exists()
59-
# PNG files start with the PNG magic bytes.
60-
assert output_file.read_bytes().startswith(b"\x89PNG\r\n\x1a\n")
61-
62-
@staticmethod
63-
def test_generate_vumark_svg(
64-
mock_database: VuforiaDatabase,
65-
vws_client: VWS,
66-
high_quality_image: io.BytesIO,
67-
tmp_path: Path,
68-
) -> None:
69-
"""It is possible to generate a VuMark as SVG."""
70-
runner = CliRunner()
71-
target_id = vws_client.add_target(
72-
name=uuid.uuid4().hex,
73-
width=1,
74-
image=high_quality_image,
75-
active_flag=True,
76-
application_metadata=None,
77-
)
78-
vws_client.wait_for_target_processed(target_id=target_id)
79-
output_file = tmp_path / "output.svg"
80-
commands = [
81-
"generate-vumark",
82-
"--target-id",
83-
target_id,
84-
"--instance-id",
85-
"12345",
86-
"--format",
87-
"svg",
88-
"--output",
89-
str(object=output_file),
90-
"--server-access-key",
91-
mock_database.server_access_key,
92-
"--server-secret-key",
93-
mock_database.server_secret_key,
94-
]
95-
result = runner.invoke(
96-
cli=vws_group,
97-
args=commands,
98-
catch_exceptions=False,
99-
color=True,
100-
)
101-
assert result.exit_code == 0
102-
assert output_file.exists()
103-
# SVG files are XML starting with "<".
104-
assert output_file.read_bytes().startswith(b"<")
105-
106-
@staticmethod
107-
def test_generate_vumark_pdf(
19+
@pytest.mark.parametrize(
20+
argnames=("format_name", "expected_prefix"),
21+
argvalues=[
22+
pytest.param("png", b"\x89PNG\r\n\x1a\n", id="png"),
23+
pytest.param("svg", b"<", id="svg"),
24+
pytest.param("pdf", b"%PDF", id="pdf"),
25+
],
26+
)
27+
def test_generate_vumark_format(
10828
mock_database: VuforiaDatabase,
10929
vws_client: VWS,
11030
high_quality_image: io.BytesIO,
11131
tmp_path: Path,
32+
format_name: str,
33+
expected_prefix: bytes,
11234
) -> None:
113-
"""It is possible to generate a VuMark as PDF."""
35+
"""The returned file matches the requested format."""
11436
runner = CliRunner()
11537
target_id = vws_client.add_target(
11638
name=uuid.uuid4().hex,
@@ -120,15 +42,15 @@ def test_generate_vumark_pdf(
12042
application_metadata=None,
12143
)
12244
vws_client.wait_for_target_processed(target_id=target_id)
123-
output_file = tmp_path / "output.pdf"
45+
output_file = tmp_path / f"output.{format_name}"
12446
commands = [
12547
"generate-vumark",
12648
"--target-id",
12749
target_id,
12850
"--instance-id",
12951
"12345",
13052
"--format",
131-
"pdf",
53+
format_name,
13254
"--output",
13355
str(object=output_file),
13456
"--server-access-key",
@@ -143,9 +65,7 @@ def test_generate_vumark_pdf(
14365
color=True,
14466
)
14567
assert result.exit_code == 0
146-
assert output_file.exists()
147-
# PDF files start with the PDF magic bytes.
148-
assert output_file.read_bytes().startswith(b"%PDF")
68+
assert output_file.read_bytes().startswith(expected_prefix)
14969

15070
@staticmethod
15171
def test_default_format_is_png(

0 commit comments

Comments
 (0)