self = <swh.search.tests.test_api_client.TestRemoteSearch testMethod=test_origin_instrinsic_metadata_dates_filter_sorting_search>
def test_origin_instrinsic_metadata_dates_filter_sorting_search(self):
DATE_0 = "1999-06-28"
DATE_1 = "2001-02-13"
DATE_2 = "2005-10-02"
ORIGINS = [
{
"url": "http://foobar.0.com",
"intrinsic_metadata": {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"dateCreated": DATE_0,
"dateModified": DATE_1,
"datePublished": DATE_2,
},
},
{
"url": "http://foobar.1.com",
"intrinsic_metadata": {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"dateCreated": DATE_1,
"dateModified": DATE_2,
"datePublished": DATE_2,
},
},
{
"url": "http://foobar.2.com",
"intrinsic_metadata": {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"dateCreated": DATE_2,
"dateModified": DATE_2,
"datePublished": DATE_2,
},
},
]
self.search.origin_update(ORIGINS)
self.search.flush()
def _check_results(origin_indices, sort_results=True, **kwargs):
page = self.search.origin_search(url_pattern="foobar", **kwargs)
results = [r["url"] for r in page.results]
if sort_results:
assert sorted(results) == sorted(
[ORIGINS[index]["url"] for index in origin_indices]
)
else:
assert results == [ORIGINS[index]["url"] for index in origin_indices]
_check_results(min_date_created=DATE_0, origin_indices=[0, 1, 2])
> _check_results(min_date_created=DATE_1, origin_indices=[1, 2])
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_search.py:461:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
origin_indices = [1, 2], sort_results = True
kwargs = {'min_date_created': '2001-02-13'}
page = PagedResult(results=[{'url': 'http://foobar.0.com'}, {'url': 'http://foobar.2.com'}], next_page_token=None)
results = ['http://foobar.0.com', 'http://foobar.2.com']
@py_assert2 = ['http://foobar.0.com', 'http://foobar.2.com']
@py_assert6 = ['http://foobar.1.com', 'http://foobar.2.com']
@py_assert8 = ['http://foobar.1.com', 'http://foobar.2.com']
@py_assert4 = False
@py_format10 = "['http://foob...foobar.2.com'] == ['http://foob...foobar.2.com']\n~At index 0 diff: 'http://foobar.0.com' != 'http://... 'http://foobar.2.com']\n~? ^\n~+ ['http://foobar.0.com', 'http://foobar.2.com']\n~? ^"
def _check_results(origin_indices, sort_results=True, **kwargs):
page = self.search.origin_search(url_pattern="foobar", **kwargs)
results = [r["url"] for r in page.results]
if sort_results:
> assert sorted(results) == sorted(
[ORIGINS[index]["url"] for index in origin_indices]
)
E AssertionError: assert ['http://foob...foobar.2.com'] == ['http://foob...foobar.2.com']
E At index 0 diff: 'http://foobar.0.com' != 'http://foobar.1.com'
E Full diff:
E - ['http://foobar.1.com', 'http://foobar.2.com']
E ? ^
E + ['http://foobar.0.com', 'http://foobar.2.com']
E ? ^
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_search.py:454: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jul 5 2021, 6:26 PM