1414# limitations under the License.
1515#
1616
17- from faker import Faker
1817from datetime import datetime
1918
19+ from faker import Faker
2020from geoalchemy2 import WKTElement
2121
22- from shared .database_gen .sqlacodegen_models import (
23- Validationreport ,
24- Feature ,
25- Redirectingid ,
26- )
2722from shared .database_gen .sqlacodegen_models import (
2823 Gtfsfeed ,
2924 Gtfsrealtimefeed ,
3025 Gtfsdataset ,
3126 Location ,
3227 Entitytype ,
3328)
29+ from shared .database_gen .sqlacodegen_models import (
30+ Validationreport ,
31+ Feature ,
32+ Redirectingid ,
33+ )
3434from test_shared .test_utils .database_utils import clean_testing_db , get_testing_session
3535
3636
@@ -48,7 +48,6 @@ def populate_database():
4848 session = get_testing_session ()
4949 fake = Faker ()
5050
51- feed_reference = None
5251 feeds = []
5352 # We create 3 feeds. The first one is active. The third one is inactive and redirected to the first one.
5453 # The second one is active but not redirected.
@@ -65,9 +64,9 @@ def populate_database():
6564 stable_id = f"gtfs-{ i } " ,
6665 feed_contact_email = f"gtfs-{ i } [email protected] " ,
6766 provider = f"gtfs-{ i } Some fake company" ,
67+ operational_status = "published" ,
68+ official = True ,
6869 )
69- if i == 0 :
70- feed_reference = feed
7170 feeds .append (feed )
7271
7372 # Then fill the specific parameters for each feed
@@ -112,6 +111,8 @@ def populate_database():
112111 status = "deprecated" ,
113112 feed_contact_email = f"gtfs-deprecated-{ i } [email protected] " ,
114113 provider = f"gtfs-deprecated-{ i } Some fake company" ,
114+ operational_status = "published" ,
115+ official = True ,
115116 )
116117 session .add (feed )
117118
@@ -187,46 +188,46 @@ def populate_database():
187188 session .add (tu_entitytype )
188189
189190 # GTFS Realtime feeds
190- rt_feeds = []
191+ gtfs_rt_feeds = []
191192 for i in range (3 ):
192- rt_feeds .append (
193- Gtfsrealtimefeed (
194- id = fake .uuid4 (),
195- data_type = "gtfs_rt" ,
196- feed_name = f"gtfs-rt-{ i } Some fake name" ,
197- note = f"gtfs-rt-{ i } Some fake note" ,
198- producer_url = f"https://gtfs-rt-{ i } _some_fake_producer_url" ,
199- authentication_type = str (i ),
200- authentication_info_url = f"https://gtfs-rt-{ i } _some_fake_authentication_info_url" ,
201- api_key_parameter_name = f"gtfs-rt-{ i } _fake_api_key_parameter_name" ,
202- license_url = f"https://gtfs-rt-{ i } _some_fake_license_url" ,
203- stable_id = f"gtfs-rt-{ i } " ,
204- status = "inactive" if i == 1 else "active" ,
205- feed_contact_email = f"gtfs-rt-{ i } [email protected] " ,
206- provider = f"gtfs-rt-{ i } Some fake company" ,
207- entitytypes = [vp_entitytype , tu_entitytype ]
208- if i == 0
209- else [vp_entitytype ],
210- gtfs_feeds = [feed_reference ] if i == 0 else [],
211- )
193+ feed = Gtfsrealtimefeed (
194+ id = fake .uuid4 (),
195+ data_type = "gtfs_rt" ,
196+ feed_name = f"gtfs-rt-{ i } Some fake name" ,
197+ note = f"gtfs-rt-{ i } Some fake note" ,
198+ producer_url = f"https://gtfs-rt-{ i } _some_fake_producer_url" ,
199+ authentication_type = str (i ),
200+ authentication_info_url = f"https://gtfs-rt-{ i } _some_fake_authentication_info_url" ,
201+ api_key_parameter_name = f"gtfs-rt-{ i } _fake_api_key_parameter_name" ,
202+ license_url = f"https://gtfs-rt-{ i } _some_fake_license_url" ,
203+ stable_id = f"gtfs-rt-{ i } " ,
204+ status = "inactive" if i == 1 else "active" ,
205+ feed_contact_email = f"gtfs-rt-{ i } [email protected] " ,
206+ provider = f"gtfs-rt-{ i } Some fake company" ,
207+ entitytypes = [vp_entitytype , tu_entitytype ] if i == 0 else [vp_entitytype ],
208+ operational_status = "published" ,
209+ official = True ,
210+ gtfs_feeds = [active_gtfs_feeds [0 ]] if i == 0 else [],
212211 )
213- # rt_feeds[1] is inactive and redirected to rt_feeds[0] and rt_feee[2]
214- rt_feeds [1 ].redirectingids = [
212+ gtfs_rt_feeds .append (feed )
213+
214+ # Add redirecting IDs (from main branch logic)
215+ gtfs_rt_feeds [1 ].redirectingids = [
215216 Redirectingid (
216- source_id = rt_feeds [1 ].id ,
217- target_id = rt_feeds [0 ].id ,
217+ source_id = gtfs_rt_feeds [1 ].id ,
218+ target_id = gtfs_rt_feeds [0 ].id ,
218219 redirect_comment = "comment 1" ,
219- target = rt_feeds [0 ],
220+ target = gtfs_rt_feeds [0 ],
220221 ),
221222 Redirectingid (
222- source_id = rt_feeds [1 ].id ,
223- target_id = rt_feeds [2 ].id ,
223+ source_id = gtfs_rt_feeds [1 ].id ,
224+ target_id = gtfs_rt_feeds [2 ].id ,
224225 redirect_comment = "comment 2" ,
225- target = rt_feeds [2 ],
226+ target = gtfs_rt_feeds [2 ],
226227 ),
227228 ]
228229
229- session .add_all (rt_feeds )
230+ session .add_all (gtfs_rt_feeds )
230231
231232 session .commit ()
232233
0 commit comments