cubicweb/test/unittest_migration.py
changeset 12629 6b314fc558ed
parent 11768 b8b71dd09a2c
child 12745 cc681b6fcffa
equal deleted inserted replaced
12628:7b89cad574f8 12629:6b314fc558ed
    20 from os.path import dirname, join
    20 from os.path import dirname, join
    21 from logilab.common.testlib import TestCase, unittest_main
    21 from logilab.common.testlib import TestCase, unittest_main
    22 
    22 
    23 from cubicweb import devtools
    23 from cubicweb import devtools
    24 from cubicweb.cwconfig import CubicWebConfiguration
    24 from cubicweb.cwconfig import CubicWebConfiguration
    25 from cubicweb.migration import filter_scripts, version_strictly_lower
    25 from cubicweb.migration import (
       
    26     filter_scripts,
       
    27     split_constraint,
       
    28     version_strictly_lower,
       
    29 )
    26 
    30 
    27 
    31 
    28 class Schema(dict):
    32 class Schema(dict):
    29     def has_entity(self, e_type):
    33     def has_entity(self, e_type):
    30         return e_type in self
    34         return e_type in self
   111         with cnx:
   115         with cnx:
   112             self.assertEqual(cnx.execute('Any SN WHERE X is CWUser, X login "admin", X in_state S, S name SN').rows,
   116             self.assertEqual(cnx.execute('Any SN WHERE X is CWUser, X login "admin", X in_state S, S name SN').rows,
   113                              [['activated']])
   117                              [['activated']])
   114         repo.shutdown()
   118         repo.shutdown()
   115 
   119 
       
   120 def test_split_constraint():
       
   121     assert split_constraint(">=0.1.0") == (">=", "0.1.0")
       
   122     assert split_constraint(">= 0.1.0") == (">=", "0.1.0")
       
   123     assert split_constraint(">0.1.1") == (">", "0.1.1")
       
   124     assert split_constraint("> 0.1.1") == (">", "0.1.1")
       
   125     assert split_constraint("<0.2.0") == ("<", "0.2.0")
       
   126     assert split_constraint("< 0.2.0") == ("<", "0.2.0")
       
   127     assert split_constraint("<=42.1.0") == ("<=", "42.1.0")
       
   128     assert split_constraint("<= 42.1.0") == ("<=", "42.1.0")
       
   129 
       
   130 
   116 if __name__ == '__main__':
   131 if __name__ == '__main__':
   117     unittest_main()
   132     unittest_main()