1515from src .db .models .impl .url .record_type .sqlalchemy import URLRecordType
1616from tests .automated .integration .readonly .helper import ReadOnlyTestHelper
1717from tests .helpers .api_test_helper import APITestHelper
18- from tests .helpers .counter import next_int
1918from tests .helpers .data_creator .core import DBDataCreator
2019from tests .helpers .data_creator .models .creation_info .county import CountyCreationInfo
2120from tests .helpers .data_creator .models .creation_info .locality import LocalityCreationInfo
@@ -33,7 +32,6 @@ async def setup_readonly_data(
3332 name = "Pennsylvania" ,
3433 iso = "PA"
3534 )
36-
3735 allegheny_county : CountyCreationInfo = await db_data_creator .create_county (
3836 state_id = pennsylvania .us_state_id ,
3937 name = "Allegheny"
@@ -46,10 +44,18 @@ async def setup_readonly_data(
4644
4745
4846 # Add Agencies
49- agency_1_id : int = await add_agency (adb_client , pittsburgh )
47+ agency_1_id : int = await add_agency (adb_client , pittsburgh .location_id )
48+ agency_2_id : int = await add_agency (adb_client , allegheny_county .location_id )
5049
5150 # Add Data Source With Linked Agency
52- url_data_source_id : int = await add_data_source (agency_1_id , db_data_creator )
51+ maximal_data_source : int = await add_maximal_data_source (
52+ agency_1_id = agency_1_id ,
53+ db_data_creator = db_data_creator
54+ )
55+ minimal_data_source : int = await add_minimal_data_source (
56+ agency_1_id = agency_1_id ,
57+ db_data_creator = db_data_creator
58+ )
5359
5460 # Add Meta URL with Linked Agency
5561 url_meta_url_id : int = await add_meta_url (agency_1_id , db_data_creator )
@@ -61,7 +67,11 @@ async def setup_readonly_data(
6167 agency_1_id = agency_1_id ,
6268 agency_1_location_id = pittsburgh .location_id ,
6369
64- url_data_source_id = url_data_source_id ,
70+ agency_2_id = agency_2_id ,
71+ agency_2_location_id = allegheny_county .location_id ,
72+
73+ maximal_data_source = maximal_data_source ,
74+ minimal_data_source = minimal_data_source ,
6575 url_meta_url_id = url_meta_url_id ,
6676 )
6777
@@ -93,7 +103,7 @@ async def add_meta_url(
93103 return url_id
94104
95105
96- async def add_data_source (
106+ async def add_maximal_data_source (
97107 agency_1_id : int ,
98108 db_data_creator : DBDataCreator
99109) -> int :
@@ -150,10 +160,41 @@ async def add_data_source(
150160 )
151161 return url_id
152162
163+ async def add_minimal_data_source (
164+ agency_1_id : int ,
165+ db_data_creator : DBDataCreator
166+ ) -> int :
167+ adb_client : AsyncDatabaseClient = db_data_creator .adb_client
168+ url = URL (
169+ scheme = "https" ,
170+ url = "minimal-ds.com" ,
171+ name = "Minimal name" ,
172+ trailing_slash = False ,
173+ collector_metadata = {},
174+ status = URLStatus .OK ,
175+ source = URLSource .ROOT_URL ,
176+ )
177+ url_id : int = await adb_client .add (url , return_id = True )
178+ await db_data_creator .create_validated_flags (
179+ url_ids = [url_id ],
180+ validation_type = URLType .DATA_SOURCE
181+ )
182+ record_type = URLRecordType (
183+ url_id = url_id ,
184+ record_type = RecordType .POLICIES_AND_CONTRACTS
185+ )
186+ await adb_client .add (record_type )
187+
188+ await db_data_creator .create_url_agency_links (
189+ url_ids = [url_id ],
190+ agency_ids = [agency_1_id ]
191+ )
192+ return url_id
193+
153194
154195async def add_agency (
155196 adb_client : AsyncDatabaseClient ,
156- pittsburgh : LocalityCreationInfo
197+ location_id : int
157198) -> int :
158199 agency_1 = Agency (
159200 name = "Agency 1" ,
@@ -164,7 +205,7 @@ async def add_agency(
164205 # Add Agency location
165206 agency_1_location = LinkAgencyLocation (
166207 agency_id = agency_id ,
167- location_id = pittsburgh . location_id ,
208+ location_id = location_id ,
168209 )
169210 await adb_client .add (agency_1_location )
170211 return agency_id
0 commit comments