euroargodev / argopy

A python library for Argo data beginners and experts
https://argopy.readthedocs.io
European Union Public License 1.2
189 stars 41 forks source link

CI tests failing with "Test_ArgoDocs::test_search[docid=None-where=abstract] - KeyError: 'AB'" #393

Open gmaze opened 2 months ago

gmaze commented 2 months ago

Some CI tests, apparently quite randomly, fail with a:

FAILED argopy/tests/test_related.py::Test_ArgoDocs::test_search[docid=None-where=abstract] - KeyError: 'AB'

eg with: https://github.com/euroargodev/argopy/actions/runs/10940750386/job/30373858695#step:11:1683

gives the error trace:

=================================== FAILURES ===================================
_____________ Test_ArgoDocs.test_search[docid=None-where=abstract] _____________

self = <argopy.tests.test_related.Test_ArgoDocs object at 0x7fd32a518a90>
where = 'abstract'
an_instance = <argopy.ArgoDocs>
- 26 documents with a DOI are available in the catalogue
> Use the method 'search' to find a document id
> Use the property 'list' to check out the catalogue content

    @pytest.mark.parametrize("where", ['title', 'abstract'], indirect=False,
                             ids=["where=%s" % t for t in ['title', 'abstract']])
    @pytest.mark.parametrize("an_instance", [None], indirect=True, ids=["docid=%s" % t for t in [None]])
    def test_search(self, where, an_instance):
        txt = "CDOM"
>       results = an_instance.search(txt, where=where)

argopy/tests/test_related.py:261: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
argopy/related/argo_documentation.py:232: in search
    if txt.lower() in ArgoDocs(docid).abstract.lower():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[KeyError('UR') raised in repr()] ArgoDocs object at 0x7fd2d77c7d90>

    @property
    def abstract(self):
        """Abstract of a document"""
        if self.docid is not None:
>           return self.ris['AB']
E           KeyError: 'AB'

argopy/related/argo_documentation.py:163: KeyError

that is very weird because this test is supposedly using a mocked http server, hence correct and always available data !

Most of the time, re-launching the failed test will make it pass on the 2nd attempt