Skip to content

Commit d0472c4

Browse files
author
Trong Nhan Mai
committed
test: improve test_macaron_db_extractor test module
1 parent 029eb0e commit d0472c4

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tests/build_spec_generator/test_macaron_db_extractor.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,34 @@ def invalid_db_session() -> Generator[Session, Any, None]:
8686
],
8787
"pkg:maven/oracle/[email protected]",
8888
3,
89-
id="When two analyses of the same PURL has the same timestamp, the component id of the latest analysis is returned.",
89+
id="two_analysis_on_the_same_purl_with_same_timestamp",
90+
),
91+
pytest.param(
92+
[
93+
(
94+
datetime(year=2025, month=5, day=6, hour=10, minute=30, second=30, tzinfo=timezone.utc),
95+
"pkg:maven/oracle/[email protected]",
96+
),
97+
(
98+
datetime(year=2025, month=12, day=6, hour=10, minute=30, second=30, tzinfo=timezone.utc),
99+
"pkg:maven/oracle/[email protected]",
100+
),
101+
(
102+
datetime(year=2025, month=5, day=6, hour=10, minute=30, second=30, tzinfo=timezone.utc),
103+
"pkg:maven/boo/[email protected]",
104+
),
105+
],
106+
"pkg:maven/oracle/[email protected]",
107+
2,
108+
id="two_analysis_on_the_same_purl_with_different_timestamp",
90109
),
91110
],
92111
)
93112
def test_lookup_latest_component(
94113
macaron_db_session: Session,
95114
input_data: list[tuple[datetime, str]],
96115
query_purl_string: str,
97-
expect_id: int | None,
116+
expect_id: int,
98117
) -> None:
99118
"""Test the lookup_latest_component function."""
100119
for utc_timestamp, purl_string in input_data:
@@ -125,6 +144,7 @@ def test_lookup_latest_component(
125144
macaron_db_session,
126145
)
127146
assert latest_component
147+
assert latest_component.purl == query_purl_string
128148
assert latest_component.id == expect_id
129149

130150

@@ -134,7 +154,7 @@ def test_lookup_latest_component(
134154
pytest.param(
135155
[],
136156
"pkg:maven/oracle/[email protected]",
137-
id="The database is empty.",
157+
id="empty_database",
138158
),
139159
pytest.param(
140160
[
@@ -148,7 +168,7 @@ def test_lookup_latest_component(
148168
),
149169
],
150170
"pkg:maven/oracle/[email protected]",
151-
id="The database is not empty, but no component matches the query PackageURL string.",
171+
id="no_component_matched_the_input_purl",
152172
),
153173
],
154174
)

0 commit comments

Comments
 (0)