[PATCH eac V2] Add test `check_order_entities`

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Tue Aug 20 16:16:02 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1563887362 -7200
#      Tue Jul 23 15:09:22 2019 +0200
# Node ID 29d25fe26992cdd05472d0809b8a815abd91e1e9
# Parent  ad79c53fe45c26447f34934f6645d2cb40d538a1
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 29d25fe26992
Add test `check_order_entities`

diff -r ad79c53fe45c -r 29d25fe26992 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,20 @@
                           'biogHist': set([229, 232]),  # empty.
                           })
 
+    def check_order_entities(self, entities, expected):
+        """ Usefull test for comparing sorted lists of actual and
+        expected entities. Make it easier to check where to add a
+        new entity or swap 2 of them.
+        """
+
+        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)



More information about the saem-devel mailing list