[PATCH eac] Add test `check_order_entities`

Frank Bessou frank.bessou at logilab.fr
Tue Aug 20 15:35:45 CEST 2019



On 20/08/2019 10:18, Guillaume Vandevelde wrote:
> # HG changeset patch
> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
> # Date 1563887362 -7200
> #      Tue Jul 23 15:09:22 2019 +0200
> # Node ID 081a77bad3f559fa162409e93c431a8ccdbc50f7
> # Parent  ad79c53fe45c26447f34934f6645d2cb40d538a1
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r 081a77bad3f5
> Add test `check_order_entities`


Can you add a comment to explain the benefit of this function over a 
simple assertCountEqual ? :)


> 
> diff -r ad79c53fe45c -r 081a77bad3f5 test/test_dataimport.py
> --- a/test/test_dataimport.py	Mon Aug 19 15:08:28 2019 +0200
> +++ b/test/test_dataimport.py	Tue Jul 23 15:09:22 2019 +0200
> @@ -518,6 +518,8 @@
>           importer = dataimport.EACCPFImporter(fpath, import_log, mock_,
>                                                extid_generator=extid_generator)
>           entities = list(importer.external_entities())
> +        # Used for an easier handling of the order error while generating the 2 lists
> +        self.check_order_entities(entities, expected)
>           self.check_external_entities(entities, expected)
>           visited = set([])
>           for x in importer._visited.values():
> @@ -538,6 +540,16 @@
>                             'biogHist': set([229, 232]),  # empty.
>                             })
>   
> +    def check_order_entities(self, entities, expected):
> +
> +        def get_sorted(elems):
> +            return sorted([(e.etype, e.extid) for e in elems
> +                           if e.etype != 'ExternalUri'], key=lambda e: e[1])
> +
> +        a_lst = get_sorted(entities)
> +        e_lst = get_sorted(expected)
> +        self.assertEquals(a_lst, e_lst)
> +
>       def test_values_from_xpath(self):
>           fname = "FRAD033_EAC_00001_simplified.xml"
>           fpath = self.datapath(fname)
> 

-- 
Frank Bessou
Logilab         https://www.logilab.fr



More information about the saem-devel mailing list