Import digest algorithm list
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 02 Mar 2017 20:12:17 +0100
changeset 2415 b9f3c646fcc6
parent 2414 b7177cc7358a
child 2416 74a05cb37aa5
Import digest algorithm list
cubicweb_seda/dataimport.py
cubicweb_seda/hooks.py
cubicweb_seda/migration/0.8.0_Any.py
cubicweb_seda/migration/data/digest_algorithms.csv
test/test_dataimport.py
test/test_hooks.py
--- a/cubicweb_seda/dataimport.py	Fri Mar 03 10:39:59 2017 +0100
+++ b/cubicweb_seda/dataimport.py	Thu Mar 02 20:12:17 2017 +0100
@@ -84,6 +84,9 @@
     (u'Langues (ISO-639-3)',
      ('seda_language_to', 'seda_description_language_to'), (),
      'languages.csv'),
+    (u"Algorithmes d'empreinte",
+     'seda_algorithm', 'SEDABinaryDataObject',
+     'digest_algorithms.csv'),
 )
 
 
--- a/cubicweb_seda/hooks.py	Fri Mar 03 10:39:59 2017 +0100
+++ b/cubicweb_seda/hooks.py	Thu Mar 02 20:12:17 2017 +0100
@@ -181,7 +181,8 @@
     # XXX factorize with data structure in dataimport
     complex_rtypes = [
         ('seda_file_format_code_list_version', 'seda_format_id_to', None),
-        # ('seda_message_digest_algorithm_code_list_version'),
+        ('seda_message_digest_algorithm_code_list_version', 'seda_algorithm',
+         'SEDABinaryDataObject'),
         ('seda_mime_type_code_list_version', 'seda_mime_type_to', None),
         ('seda_encoding_code_list_version', 'seda_encoding_to', None),
         ('seda_data_object_version_code_list_version', 'seda_data_object_version_to', None),
--- a/cubicweb_seda/migration/0.8.0_Any.py	Fri Mar 03 10:39:59 2017 +0100
+++ b/cubicweb_seda/migration/0.8.0_Any.py	Thu Mar 02 20:12:17 2017 +0100
@@ -22,7 +22,7 @@
     drop_entity_type(etype)
 
 lcsv_files = [file_def for file_def in LCSV_FILES
-              if file_def[-1] == 'legal_status.csv']
+              if file_def[-1] in ('legal_status.csv', 'digest_algorithms.csv')]
 import_seda_schemes(cnx, lcsv_files=lcsv_files)
 
 drop_relation_type('seda_reply_code_list_version')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb_seda/migration/data/digest_algorithms.csv	Thu Mar 02 20:12:17 2017 +0100
@@ -0,0 +1,50 @@
+#;$id;label
+type;url;string
+lang;;en
+url;skos:Concept;skos:prefLabel
+;;md2
+;;md4
+;;md5
+;;sha1
+;;sha224
+;;sha256
+;;sha384
+;;sha512
+;;ripemd128
+;;ripemd160
+;;ripemd256
+;;ripemd320
+;;whirlpool
+;;tiger128,3
+;;tiger160,3
+;;tiger192,3
+;;tiger128,4
+;;tiger160,4
+;;tiger192,4
+;;snefru
+;;snefru256
+;;gost
+;;gost-crypto
+;;adler32
+;;crc32
+;;crc32b
+;;fnv132
+;;fnv1a32
+;;fnv164
+;;fnv1a64
+;;joaat
+;;haval128,3
+;;haval160,3
+;;haval192,3
+;;haval224,3
+;;haval256,3
+;;haval128,4
+;;haval160,4
+;;haval192,4
+;;haval224,4
+;;haval256,4
+;;haval128,5
+;;haval160,5
+;;haval192,5
+;;haval224,5
+;;haval256,5
--- a/test/test_dataimport.py	Fri Mar 03 10:39:59 2017 +0100
+++ b/test/test_dataimport.py	Thu Mar 02 20:12:17 2017 +0100
@@ -25,7 +25,7 @@
     def test_import_seda_schemes(self):
         with self.admin_access.client_cnx() as cnx:
             dataimport.import_seda_schemes(cnx, lcsv_import=dataimport.lcsv_check)
-            self.assertEqual(len(cnx.find('ConceptScheme')), 16)
+            self.assertEqual(len(cnx.find('ConceptScheme')), 17)
 
 
 if __name__ == '__main__':
--- a/test/test_hooks.py	Fri Mar 03 10:39:59 2017 +0100
+++ b/test/test_hooks.py	Thu Mar 02 20:12:17 2017 +0100
@@ -136,7 +136,8 @@
             for rtype, etype in chain(zip(('seda_format_id_to', 'seda_mime_type_to',
                                            'seda_encoding_to'),
                                           repeat(None)),
-                                      [('seda_rule', 'SEDASeqAppraisalRuleRule'),
+                                      [('seda_algorithm', 'SEDABinaryDataObject'),
+                                       ('seda_rule', 'SEDASeqAppraisalRuleRule'),
                                        ('seda_rule', 'SEDASeqAccessRuleRule')]):
                 scheme_for_type(cnx, rtype, etype)
             cnx.commit()
@@ -144,6 +145,7 @@
             cnx.commit()
 
             self.assertTrue(transfer.reverse_seda_file_format_code_list_version_from)
+            self.assertTrue(transfer.reverse_seda_message_digest_algorithm_code_list_version_from)
             self.assertTrue(transfer.reverse_seda_mime_type_code_list_version_from)
             self.assertTrue(transfer.reverse_seda_encoding_code_list_version_from)
             self.assertTrue(transfer.reverse_seda_access_rule_code_list_version_from)