[hooks / test] Allow to give raw mime types / format ids to assertFormatEquals
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Nov 2017 11:56:48 +0100
changeset 2863 33b32481052f
parent 2862 f434324b01f0
child 2864 11196b772ee1
[hooks / test] Allow to give raw mime types / format ids to assertFormatEquals instead of concept entities. Related to #39322647
test/test_hooks.py
--- a/test/test_hooks.py	Fri Nov 03 11:44:31 2017 +0100
+++ b/test/test_hooks.py	Fri Nov 03 11:56:48 2017 +0100
@@ -242,8 +242,8 @@
             bdo.cw_set(file_category=categories['document'])
             cnx.commit()
             self.assertFormatEqual(bdo,
-                                   [concepts['application/msword'], concepts['application/pdf']],
-                                   [concepts['fmt/37'], concepts['fmt/38'], concepts['fmt/14']])
+                                   ['application/msword', 'application/pdf'],
+                                   ['fmt/37', 'fmt/38', 'fmt/14'])
 
             bdo.cw_set(file_category=None)
             cnx.commit()
@@ -252,8 +252,8 @@
             bdo.cw_set(file_category=categories['doc'])
             cnx.commit()
             self.assertFormatEqual(bdo,
-                                   [concepts['application/msword']],
-                                   [concepts['fmt/37'], concepts['fmt/38']])
+                                   ['application/msword'],
+                                   ['fmt/37', 'fmt/38'])
 
             # test no dispatch occurs on component archive unit...
             unit_comp, unit_comp_alt, unit_comp_alt_seq = testutils.create_archive_unit(
@@ -272,17 +272,17 @@
             transfer.cw_clear_relation_cache('seda_binary_data_object', 'object')
             imported_bdo, = [x for x in transfer.binary_data_objects if x.eid != bdo.eid]
             self.assertFormatEqual(imported_bdo,
-                                   [concepts['application/msword'], concepts['application/pdf']],
-                                   [concepts['fmt/37'], concepts['fmt/38'], concepts['fmt/14']])
+                                   ['application/msword', 'application/pdf'],
+                                   ['fmt/37', 'fmt/38', 'fmt/14'])
 
-    def assertFormatEqual(self, bdo, mime_types, format_ids):
+    def assertFormatEqual(self, bdo, expected_mime_types, expected_format_ids):
         bdo.cw_clear_all_caches()
         bdo.reverse_seda_mime_type_from[0].cw_clear_all_caches()
         bdo.reverse_seda_format_id_from[0].cw_clear_all_caches()
-        self.assertEqual(set(x.eid for x in bdo.reverse_seda_mime_type_from[0].seda_mime_type_to),
-                         set(mime_types))
-        self.assertEqual(set(x.eid for x in bdo.reverse_seda_format_id_from[0].seda_format_id_to),
-                         set(format_ids))
+        mime_types = set(x.label() for x in bdo.reverse_seda_mime_type_from[0].seda_mime_type_to)
+        self.assertEqual(mime_types, set(expected_mime_types))
+        format_ids = set(x.label() for x in bdo.reverse_seda_format_id_from[0].seda_format_id_to)
+        self.assertEqual(format_ids, set(expected_format_ids))
 
 
 if __name__ == '__main__':