[PATCH 10 of 11 seda V2] Import digest algorithm list

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 3 11:22:43 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1488481937 -3600
#      Thu Mar 02 20:12:17 2017 +0100
# Node ID b9f3c646fcc6ee4719c6f897cdef1d2bf3bcfc47
# Parent  b7177cc7358a802adb0357fa04b5341255d4c4fd
Import digest algorithm list

diff --git a/cubicweb_seda/dataimport.py b/cubicweb_seda/dataimport.py
--- a/cubicweb_seda/dataimport.py
+++ b/cubicweb_seda/dataimport.py
@@ -82,10 +82,13 @@ LCSV_FILES = (
      'seda_classification_level', (),
      'classification_levels.csv'),
     (u'Langues (ISO-639-3)',
      ('seda_language_to', 'seda_description_language_to'), (),
      'languages.csv'),
+    (u"Algorithmes d'empreinte",
+     'seda_algorithm', 'SEDABinaryDataObject',
+     'digest_algorithms.csv'),
 )
 
 
 def lcsv_import(cnx, store, fname, scheme_uri):
     """Actually import LCSV data file."""
diff --git a/cubicweb_seda/hooks.py b/cubicweb_seda/hooks.py
--- a/cubicweb_seda/hooks.py
+++ b/cubicweb_seda/hooks.py
@@ -179,11 +179,12 @@ class SetDefaultCodeListVersionsHook(hoo
 class SetDefaultCodeListVersionsOp(hook.Operation):
     """Set sensible default values for a transfer's code list versions."""
     # 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),
         ('seda_relationship_code_list_version', 'seda_type_relationship', None),
         ('seda_access_rule_code_list_version', 'seda_rule', 'SEDASeqAccessRuleRule'),
diff --git a/cubicweb_seda/migration/0.8.0_Any.py b/cubicweb_seda/migration/0.8.0_Any.py
--- a/cubicweb_seda/migration/0.8.0_Any.py
+++ b/cubicweb_seda/migration/0.8.0_Any.py
@@ -20,9 +20,9 @@ for etype in ('SEDArestrictionRuleIdRef'
               'SEDArestrictionValue',
               'SEDArestrictionEndDate'):
     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')
diff --git a/cubicweb_seda/migration/data/digest_algorithms.csv b/cubicweb_seda/migration/data/digest_algorithms.csv
new file mode 100644
--- /dev/null
+++ b/cubicweb_seda/migration/data/digest_algorithms.csv
@@ -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
diff --git a/test/test_dataimport.py b/test/test_dataimport.py
--- a/test/test_dataimport.py
+++ b/test/test_dataimport.py
@@ -23,11 +23,11 @@ from cubicweb_seda import dataimport
 class ConcepSchemeImportTC(CubicWebTC):
 
     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__':
     import unittest
     unittest.main()
diff --git a/test/test_hooks.py b/test/test_hooks.py
--- a/test/test_hooks.py
+++ b/test/test_hooks.py
@@ -134,18 +134,20 @@ class SetDefaultHooksTC(CubicWebTC):
     def test_default_code_list_version(self):
         with self.admin_access.client_cnx() as cnx:
             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()
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             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)
             self.assertTrue(transfer.reverse_seda_appraisal_rule_code_list_version_from)
 


More information about the saem-devel mailing list