@@ -1923,6 +1923,28 @@ def api_settings(settings):
19231923 return settings
19241924
19251925
1926+ @pytest .fixture (scope = 'function' )
1927+ def assemble_api_test_records (assemble_test_records , api_solr_env ,
1928+ basic_solr_assembler ):
1929+ """
1930+ Pytest fixture. Returns a helper function that assembles & loads a
1931+ set of test records (for one test) into the api_solr_env test-data
1932+ environment fixture.
1933+
1934+ Required args include a `profile` string, the name of the unique
1935+ `id_field` for each record (for test_data record uniqueness), and a
1936+ set of static `test_data` partial records. Returns a tuple of
1937+ default solr_env records and the new test records that were loaded
1938+ from the provided test data. len(env_recs) + len(test_recs) should
1939+ equal the total number of Solr records for that profile.
1940+ """
1941+ def _assemble_api_test_records (profile , id_field , test_data ):
1942+ return assemble_test_records (profile , id_field , test_data ,
1943+ env = api_solr_env ,
1944+ assembler = basic_solr_assembler )
1945+ return _assemble_api_test_records
1946+
1947+
19261948# TESTS
19271949# ---------------------------------------------------------------------
19281950
@@ -2179,8 +2201,8 @@ def test_list_view_pagination(resource, default_limit, max_limit, limit,
21792201 ids = compile_ids (PARAMETERS__FILTER_TESTS__INTENDED ) +
21802202 compile_ids (PARAMETERS__FILTER_TESTS__STRANGE ))
21812203def test_list_view_filters (resource , test_data , search , expected , api_settings ,
2182- assemble_test_records , api_client , get_found_ids ,
2183- do_filter_search ):
2204+ assemble_api_test_records , api_client ,
2205+ get_found_ids , do_filter_search ):
21842206 """
21852207 Given the provided `test_data` records: requesting the given
21862208 `resource` using the provided search filter parameters (`search`)
@@ -2193,7 +2215,7 @@ def test_list_view_filters(resource, test_data, search, expected, api_settings,
21932215
21942216 profile = RESOURCE_METADATA [resource ]['profile' ]
21952217 id_field = RESOURCE_METADATA [resource ]['id_field' ]
2196- erecs , trecs = assemble_test_records (profile , id_field , test_data )
2218+ erecs , trecs = assemble_api_test_records (profile , id_field , test_data )
21972219
21982220 # First let's do a quick sanity check to make sure the resource
21992221 # returns the correct num of records before the filter is applied.
@@ -2213,8 +2235,8 @@ def test_list_view_filters(resource, test_data, search, expected, api_settings,
22132235 ids = compile_ids (PARAMETERS__ORDERBY_TESTS__INTENDED ) +
22142236 compile_ids (PARAMETERS__ORDERBY_TESTS__STRANGE ))
22152237def test_list_view_orderby (resource , test_data , search , expected , api_settings ,
2216- assemble_test_records , api_client , get_found_ids ,
2217- do_filter_search ):
2238+ assemble_api_test_records , api_client ,
2239+ get_found_ids , do_filter_search ):
22182240 """
22192241 Given the provided `test_data` records: requesting the given
22202242 `resource` using the provided search filter parameters (`search`)
@@ -2223,7 +2245,7 @@ def test_list_view_orderby(resource, test_data, search, expected, api_settings,
22232245 """
22242246 profile = RESOURCE_METADATA [resource ]['profile' ]
22252247 id_field = RESOURCE_METADATA [resource ]['id_field' ]
2226- erecs , trecs = assemble_test_records (profile , id_field , test_data )
2248+ erecs , trecs = assemble_api_test_records (profile , id_field , test_data )
22272249 print [r .get ('call_number_sort' , None ) for r in trecs ]
22282250 resource_url = '{}{}/' .format (API_ROOT , resource )
22292251 response = do_filter_search (resource_url , search , api_client )
@@ -2235,7 +2257,7 @@ def test_list_view_orderby(resource, test_data, search, expected, api_settings,
22352257 compile_params (PARAMETERS__FIRSTITEMPERLOCATION ),
22362258 ids = compile_ids (PARAMETERS__FIRSTITEMPERLOCATION ))
22372259def test_firstitemperlocation_list (test_data , search , expected , api_settings ,
2238- assemble_test_records , api_client ,
2260+ assemble_api_test_records , api_client ,
22392261 get_found_ids , do_filter_search ):
22402262 """
22412263 The `firstitemperlocation` resource is basically a custom filter
@@ -2257,7 +2279,7 @@ def test_firstitemperlocation_list(test_data, search, expected, api_settings,
22572279 for resource in data .keys ():
22582280 profile = RESOURCE_METADATA [resource ]['profile' ]
22592281 id_field = RESOURCE_METADATA [resource ]['id_field' ]
2260- assemble_test_records (profile , id_field , data [resource ])
2282+ assemble_api_test_records (profile , id_field , data [resource ])
22612283
22622284 resource_url = '{}firstitemperlocation/' .format (API_ROOT )
22632285 rsp = do_filter_search (resource_url , search , api_client )
@@ -2270,7 +2292,7 @@ def test_firstitemperlocation_list(test_data, search, expected, api_settings,
22702292 compile_params (PARAMETERS__CALLNUMBERMATCHES ),
22712293 ids = compile_ids (PARAMETERS__CALLNUMBERMATCHES ))
22722294def test_callnumbermatches_list (test_data , search , expected , api_settings ,
2273- assemble_test_records , api_client ,
2295+ assemble_api_test_records , api_client ,
22742296 do_filter_search ):
22752297 """
22762298 The `callnumbermatches` resource simply returns an array of
@@ -2287,7 +2309,7 @@ def test_callnumbermatches_list(test_data, search, expected, api_settings,
22872309 for resource in data .keys ():
22882310 profile = RESOURCE_METADATA [resource ]['profile' ]
22892311 id_field = RESOURCE_METADATA [resource ]['id_field' ]
2290- assemble_test_records (profile , id_field , data [resource ])
2312+ assemble_api_test_records (profile , id_field , data [resource ])
22912313
22922314 resource_url = '{}callnumbermatches/' .format (API_ROOT )
22932315 response = do_filter_search (resource_url , search , api_client )
0 commit comments