Skip to content

Commit 0583f03

Browse files
committed
add test coverage
1 parent 9f7d8c7 commit 0583f03

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

api/src/feeds/impl/models/search_feed_item_result_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def from_orm_gtfs(cls, feed_search_row: t_feedsearch):
5151
service_date_range_end=feed_search_row.latest_dataset_service_date_range_end,
5252
agency_timezone=feed_search_row.latest_dataset_agency_timezone,
5353
validation_report=LatestDatasetValidationReport(
54-
total_error=feed_search_row.latest_total_error.la.total_error,
54+
total_error=feed_search_row.latest_total_error,
5555
total_warning=feed_search_row.latest_total_warning,
5656
total_info=feed_search_row.latest_total_info,
5757
unique_error_count=feed_search_row.latest_unique_error_count,

api/tests/unittest/models/test_gtfs_feed_impl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def create_test_notice(notice_code: str, total_notices: int, severity: str):
172172
unique_error_count=3,
173173
unique_warning_count=4,
174174
unique_info_count=2,
175+
features=["feature"],
175176
),
176177
service_date_range_start=datetime(2024, 1, 1, 0, 0, 0, tzinfo=ZoneInfo("Canada/Atlantic")),
177178
service_date_range_end=datetime(2025, 1, 1, 0, 0, 0, tzinfo=ZoneInfo("Canada/Atlantic")),

api/tests/unittest/models/test_latest_dataset_impl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from geoalchemy2 import WKTElement
66

7-
from shared.database_gen.sqlacodegen_models import Gtfsdataset, Feed, Validationreport
7+
from shared.database_gen.sqlacodegen_models import Gtfsdataset, Feed, Validationreport, Feature
88
from feeds.impl.models.bounding_box_impl import BoundingBoxImpl
99
from feeds.impl.models.latest_dataset_impl import LatestDatasetImpl
1010

@@ -36,6 +36,7 @@ def test_from_orm(self):
3636
unique_error_count=0,
3737
unique_warning_count=0,
3838
unique_info_count=0,
39+
features=[],
3940
),
4041
Validationreport(
4142
validator_version="1.2.0",
@@ -45,6 +46,7 @@ def test_from_orm(self):
4546
unique_error_count=2,
4647
unique_warning_count=1,
4748
unique_info_count=1,
49+
features=[Feature(name="feature 1.2.0 1"), Feature(name="feature 1.2.0 2")],
4850
),
4951
Validationreport(
5052
validator_version="1.1.1",
@@ -54,6 +56,7 @@ def test_from_orm(self):
5456
unique_error_count=1,
5557
unique_warning_count=1,
5658
unique_info_count=0,
59+
features=[Feature(name="feature 1.1.1 1"), Feature(name="feature 1.1.1 2")],
5760
),
5861
],
5962
)
@@ -74,6 +77,7 @@ def test_from_orm(self):
7477
service_date_range_end=datetime(2025, 1, 1, 0, 0, 0, tzinfo=ZoneInfo("Canada/Atlantic")),
7578
agency_timezone="Canada/Atlantic",
7679
validation_report={
80+
"features": ["feature 1.2.0 1", "feature 1.2.0 2"],
7781
"validator_version": "1.2.0",
7882
"total_error": 3,
7983
"total_info": 1,

api/tests/unittest/models/test_search_feed_item_result_impl.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from feeds.impl.models.search_feed_item_result_impl import SearchFeedItemResultImpl
77
from feeds_gen.models.latest_dataset import LatestDataset
8+
from feeds_gen.models.latest_dataset_validation_report import LatestDatasetValidationReport
89
from feeds_gen.models.location import Location
910
from feeds_gen.models.source_info import SourceInfo
1011

@@ -43,6 +44,13 @@ def __init__(self, **kwargs):
4344
latest_dataset_service_date_range_start="2030-09-29T00:00:00+00:00",
4445
latest_dataset_service_date_range_end="2031-09-29T00:00:00+00:00",
4546
latest_dataset_agency_timezone="Canada/Atlantic",
47+
latest_total_error=1,
48+
latest_total_warning=2,
49+
latest_total_info=3,
50+
latest_unique_error_count=1,
51+
latest_unique_warning_count=2,
52+
latest_unique_info_count=3,
53+
latest_dataset_features=["feature1", "feature2"],
4654
external_ids=[],
4755
redirect_ids=[],
4856
feed_reference_ids=[],
@@ -86,6 +94,15 @@ def test_from_orm_gtfs(self):
8694
service_date_range_start=item.latest_dataset_service_date_range_start,
8795
service_date_range_end=item.latest_dataset_service_date_range_end,
8896
agency_timezone=item.latest_dataset_agency_timezone,
97+
validation_report=LatestDatasetValidationReport(
98+
total_error=item.latest_total_error,
99+
total_warning=item.latest_total_warning,
100+
total_info=item.latest_total_info,
101+
unique_error_count=item.latest_unique_error_count,
102+
unique_warning_count=item.latest_unique_warning_count,
103+
unique_info_count=item.latest_unique_info_count,
104+
features=item.latest_dataset_features,
105+
),
89106
),
90107
)
91108
assert result == expected

0 commit comments

Comments
 (0)