test/unittest_utils.py
changeset 8682 20bd1cdf86ae
parent 7954 a3d3220669d6
child 9599 13dd3a57dabb
equal deleted inserted replaced
8677:a75bb09d6d19 8682:20bd1cdf86ae
    24 
    24 
    25 from logilab.common.testlib import TestCase, DocTest, unittest_main
    25 from logilab.common.testlib import TestCase, DocTest, unittest_main
    26 
    26 
    27 from cubicweb.devtools.testlib import CubicWebTC
    27 from cubicweb.devtools.testlib import CubicWebTC
    28 from cubicweb.utils import (make_uid, UStringIO, SizeConstrainedList,
    28 from cubicweb.utils import (make_uid, UStringIO, SizeConstrainedList,
    29                             RepeatList, HTMLHead, QueryCache)
    29                             RepeatList, HTMLHead, QueryCache, parse_repo_uri)
    30 from cubicweb.entity import Entity
    30 from cubicweb.entity import Entity
    31 
    31 
    32 try:
    32 try:
    33     from cubicweb.utils import CubicWebJsonEncoder, json
    33     from cubicweb.utils import CubicWebJsonEncoder, json
    34 except ImportError:
    34 except ImportError:
    47                 self.fail(len(d))
    47                 self.fail(len(d))
    48             if re.match('\d', uid):
    48             if re.match('\d', uid):
    49                 self.fail('make_uid must not return something begining with '
    49                 self.fail('make_uid must not return something begining with '
    50                           'some numeric character, got %s' % uid)
    50                           'some numeric character, got %s' % uid)
    51             d.add(uid)
    51             d.add(uid)
       
    52 
       
    53 
       
    54 class TestParseRepoUri(TestCase):
       
    55 
       
    56     def test_parse_repo_uri(self):
       
    57         self.assertEqual(('inmemory', None, 'myapp'),
       
    58                          parse_repo_uri('myapp'))
       
    59         self.assertEqual(('inmemory', None, 'myapp'),
       
    60                          parse_repo_uri('inmemory://myapp'))
       
    61         self.assertEqual(('pyro', 'pyro-ns-host:pyro-ns-port', '/myapp'),
       
    62                          parse_repo_uri('pyro://pyro-ns-host:pyro-ns-port/myapp'))
       
    63         self.assertEqual(('pyroloc', 'host:port', '/appkey'),
       
    64                          parse_repo_uri('pyroloc://host:port/appkey'))
       
    65         self.assertEqual(('zmqpickle-tcp', '127.0.0.1:666', ''),
       
    66                          parse_repo_uri('zmqpickle-tcp://127.0.0.1:666'))
       
    67         with self.assertRaises(NotImplementedError):
       
    68             parse_repo_uri('foo://bar')
       
    69 
       
    70 
    52 
    71 
    53 class TestQueryCache(TestCase):
    72 class TestQueryCache(TestCase):
    54     def test_querycache(self):
    73     def test_querycache(self):
    55         c = QueryCache(ceiling=20)
    74         c = QueryCache(ceiling=20)
    56         # write only
    75         # write only