cubicweb/test/unittest_utils.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 24 Nov 2016 15:36:26 +0100
changeset 11892 08cf02efc7ce
parent 11715 760d5c0ae08f
child 11917 c38e13988c10
permissions -rw-r--r--
Simplify and fix _cw.drop_entity_cache * it's never called with an eid as argument, beside in a useless case in test (removed) * the only place where it's called from outside the tests is in full-text reindexation in server.checkintegrity: we could removed the request implementation and move it in unittest_rset, byt I decided to keep it for consistency with all other entity cache handling methods * get back a fix from Julien Cristau for the connection's implementation, quoting is commit message: When removing an entity from the transaction's cache, clear the entity's own cache May avoid issues where an entity object is still accessible somewhere else (e.g. an operation) after dropping it from the transaction's cache, with a stale attribute or relation cache.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9599
13dd3a57dabb [test/utils] repair concat-resources test
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8682
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5389
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    18
"""unit tests for module cubicweb.utils"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
11715
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    20
import base64
11078
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    21
import datetime
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
    22
import decimal
11078
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    23
import doctest
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
    24
import re
11715
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    25
try:
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    26
    from unittest2 import TestCase
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    27
except ImportError:  # Python3
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    28
    from unittest import TestCase
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
    29
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
    30
from six.moves import range
7569
02c338197322 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7277 7568
diff changeset
    31
11715
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
    32
from cubicweb import Binary
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
    33
from cubicweb.devtools.testlib import CubicWebTC
10933
830f1ea52789 [utils] Drop now-unused SizeConstrainedList
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10609
diff changeset
    34
from cubicweb.utils import (make_uid, UStringIO, RepeatList, HTMLHead,
830f1ea52789 [utils] Drop now-unused SizeConstrainedList
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10609
diff changeset
    35
                            QueryCache, parse_repo_uri)
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    36
from cubicweb.entity import Entity
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
4694
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    38
try:
5389
809d3b5b3d31 [python2.6] careful: json-py provides a json package. We don't want that.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5377
diff changeset
    39
    from cubicweb.utils import CubicWebJsonEncoder, json
4694
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    40
except ImportError:
5377
84d14ddfae13 [python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5077
diff changeset
    41
    json = None
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
class MakeUidTC(TestCase):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
    def test_1(self):
6415
b0b0f097a72d cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
    45
        self.assertNotEqual(make_uid('xyz'), make_uid('abcd'))
b0b0f097a72d cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
    46
        self.assertNotEqual(make_uid('xyz'), make_uid('xyz'))
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 720
diff changeset
    47
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
    def test_2(self):
3146
cfc4344023f2 have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents: 2635
diff changeset
    49
        d = set()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
        while len(d)<10000:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
            uid = make_uid('xyz')
3146
cfc4344023f2 have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents: 2635
diff changeset
    52
            if uid in d:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    53
                self.fail(len(d))
4694
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    54
            if re.match('\d', uid):
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    55
                self.fail('make_uid must not return something begining with '
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    56
                          'some numeric character, got %s' % uid)
3146
cfc4344023f2 have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents: 2635
diff changeset
    57
            d.add(uid)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
8682
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    59
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    60
class TestParseRepoUri(TestCase):
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    61
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    62
    def test_parse_repo_uri(self):
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    63
        self.assertEqual(('inmemory', None, 'myapp'),
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    64
                         parse_repo_uri('myapp'))
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    65
        self.assertEqual(('inmemory', None, 'myapp'),
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    66
                         parse_repo_uri('inmemory://myapp'))
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    67
        with self.assertRaises(NotImplementedError):
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    68
            parse_repo_uri('foo://bar')
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    69
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    70
20bd1cdf86ae [cwctl] fix cubicweb-ctl shell command (closes #2583919)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7954
diff changeset
    71
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    72
class TestQueryCache(TestCase):
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    73
    def test_querycache(self):
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    74
        c = QueryCache(ceiling=20)
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    75
        # write only
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
    76
        for x in range(10):
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    77
            c[x] = x
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    78
        self.assertEqual(c._usage_report(),
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    79
                         {'transientcount': 0,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    80
                          'itemcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    81
                          'permanentcount': 0})
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    82
        c = QueryCache(ceiling=10)
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    83
        # we should also get a warning
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
    84
        for x in range(20):
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    85
            c[x] = x
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    86
        self.assertEqual(c._usage_report(),
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    87
                         {'transientcount': 0,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    88
                          'itemcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    89
                          'permanentcount': 0})
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    90
        # write + reads
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    91
        c = QueryCache(ceiling=20)
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
    92
        for n in range(4):
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
    93
            for x in range(10):
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    94
                c[x] = x
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    95
                c[x]
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    96
        self.assertEqual(c._usage_report(),
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    97
                         {'transientcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    98
                          'itemcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
    99
                          'permanentcount': 0})
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   100
        c = QueryCache(ceiling=20)
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
   101
        for n in range(17):
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
   102
            for x in range(10):
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   103
                c[x] = x
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   104
                c[x]
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   105
        self.assertEqual(c._usage_report(),
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   106
                         {'transientcount': 0,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   107
                          'itemcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   108
                          'permanentcount': 10})
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   109
        c = QueryCache(ceiling=20)
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
   110
        for n in range(17):
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10600
diff changeset
   111
            for x in range(10):
7954
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   112
                c[x] = x
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   113
                if n % 2:
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   114
                    c[x]
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   115
                if x % 2:
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   116
                    c[x]
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   117
        self.assertEqual(c._usage_report(),
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   118
                         {'transientcount': 5,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   119
                          'itemcount': 10,
a3d3220669d6 [cache] replace lgc.cache with something more appropriate (closes #1921713)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 7791
diff changeset
   120
                          'permanentcount': 5})
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 720
diff changeset
   121
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
class UStringIOTC(TestCase):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
    def test_boolean_value(self):
10600
180aa08cad48 [tests] Replace use of deprecated TestCase.assert_
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10236
diff changeset
   124
        self.assertTrue(UStringIO())
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   125
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   127
class RepeatListTC(TestCase):
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   128
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   129
    def test_base(self):
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   130
        l = RepeatList(3, (1, 3))
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   131
        self.assertEqual(l[0], (1, 3))
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   132
        self.assertEqual(l[2], (1, 3))
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   133
        self.assertEqual(l[-1], (1, 3))
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   134
        self.assertEqual(len(l), 3)
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   135
        # XXX
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   136
        self.assertEqual(l[4], (1, 3))
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   137
7791
31bb51ea5485 [deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7762
diff changeset
   138
        self.assertFalse(RepeatList(0, None))
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   139
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   140
    def test_slice(self):
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   141
        l = RepeatList(3, (1, 3))
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   142
        self.assertEqual(l[0:1], [(1, 3)])
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   143
        self.assertEqual(l[0:4], [(1, 3)]*3)
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   144
        self.assertEqual(l[:], [(1, 3)]*3)
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   145
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   146
    def test_iter(self):
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   147
        self.assertEqual(list(RepeatList(3, (1, 3))),
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   148
                          [(1, 3)]*3)
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   149
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   150
    def test_add(self):
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   151
        l = RepeatList(3, (1, 3))
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   152
        self.assertEqual(l + [(1, 4)], [(1, 3)]*3  + [(1, 4)])
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   153
        self.assertEqual([(1, 4)] + l, [(1, 4)] + [(1, 3)]*3)
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   154
        self.assertEqual(l + RepeatList(2, (2, 3)), [(1, 3)]*3 + [(2, 3)]*2)
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   155
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   156
        x = l + RepeatList(2, (1, 3))
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   157
        self.assertIsInstance(x, RepeatList)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   158
        self.assertEqual(len(x), 5)
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   159
        self.assertEqual(x[0], (1, 3))
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   160
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   161
        x = l + [(1, 3)] * 2
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   162
        self.assertEqual(x, [(1, 3)] * 5)
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   163
5077
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   164
    def test_eq(self):
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   165
        self.assertEqual(RepeatList(3, (1, 3)),
5077
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   166
                          [(1, 3)]*3)
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   167
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   168
    def test_pop(self):
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   169
        l = RepeatList(3, (1, 3))
dc448c9ad9dd [rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5069
diff changeset
   170
        l.pop(2)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   171
        self.assertEqual(l, [(1, 3)]*2)
5069
135c5d7b89d0 [querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4890
diff changeset
   172
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   173
4890
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4694
diff changeset
   174
class JSONEncoderTC(TestCase):
4694
c19366a12281 simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   175
    def setUp(self):
5377
84d14ddfae13 [python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5077
diff changeset
   176
        if json is None:
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   177
            self.skipTest('json not available')
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   178
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   179
    def encode(self, value):
5377
84d14ddfae13 [python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5077
diff changeset
   180
        return json.dumps(value, cls=CubicWebJsonEncoder)
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   181
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   182
    def test_encoding_dates(self):
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   183
        self.assertEqual(self.encode(datetime.datetime(2009, 9, 9, 20, 30)),
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   184
                          '"2009/09/09 20:30:00"')
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   185
        self.assertEqual(self.encode(datetime.date(2009, 9, 9)),
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   186
                          '"2009/09/09"')
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   187
        self.assertEqual(self.encode(datetime.time(20, 30)),
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   188
                          '"20:30:00"')
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   189
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   190
    def test_encoding_decimal(self):
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   191
        self.assertEqual(self.encode(decimal.Decimal('1.2')), '1.2')
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   192
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   193
    def test_encoding_bare_entity(self):
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   194
        e = Entity(None)
6142
8bc6eac1fac1 [session] cleanup hook / operation / entity edition api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   195
        e.cw_attr_cache['pouet'] = 'hop'
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   196
        e.eid = 2
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   197
        self.assertEqual(json.loads(self.encode(e)),
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   198
                          {'pouet': 'hop', 'eid': 2})
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   199
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   200
    def test_encoding_entity_in_list(self):
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   201
        e = Entity(None)
6142
8bc6eac1fac1 [session] cleanup hook / operation / entity edition api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   202
        e.cw_attr_cache['pouet'] = 'hop'
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   203
        e.eid = 2
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   204
        self.assertEqual(json.loads(self.encode([e])),
5726
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   205
                          [{'pouet': 'hop', 'eid': 2}])
c3b99606644d [json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   206
11715
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   207
    def test_encoding_binary(self):
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   208
        for content in (b'he he', b'h\xe9 hxe9'):
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   209
            with self.subTest(content=content):
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   210
                encoded = self.encode(Binary(content))
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   211
                self.assertEqual(base64.b64decode(encoded), content)
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   212
3231
3ee43e2f8560 [utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2635
diff changeset
   213
    def test_encoding_unknown_stuff(self):
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5726
diff changeset
   214
        self.assertEqual(self.encode(TestCase), 'null')
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 720
diff changeset
   215
11714
73201a210007 [test] Make cubicweb/test/unittest_utils.py flake8-clean
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11078
diff changeset
   216
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   217
class HTMLHeadTC(CubicWebTC):
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   218
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   219
    def htmlhead(self, datadir_url):
9657
3ff4c6f80c37 [test] update unittest_utils to 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9599
diff changeset
   220
        with self.admin_access.web_request() as req:
3ff4c6f80c37 [test] update unittest_utils to 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9599
diff changeset
   221
            base_url = u'http://test.fr/data/'
3ff4c6f80c37 [test] update unittest_utils to 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9599
diff changeset
   222
            req.datadir_url = base_url
3ff4c6f80c37 [test] update unittest_utils to 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9599
diff changeset
   223
            head = HTMLHead(req)
3ff4c6f80c37 [test] update unittest_utils to 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9599
diff changeset
   224
            return head
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   225
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   226
    def test_concat_urls(self):
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   227
        base_url = u'http://test.fr/data/'
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   228
        head = self.htmlhead(base_url)
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   229
        urls = [base_url + u'bob1.js',
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   230
                base_url + u'bob2.js',
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   231
                base_url + u'bob3.js']
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   232
        result = head.concat_urls(urls)
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   233
        expected = u'http://test.fr/data/??bob1.js,bob2.js,bob3.js'
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   234
        self.assertEqual(result, expected)
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   235
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   236
    def test_group_urls(self):
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   237
        base_url = u'http://test.fr/data/'
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   238
        head = self.htmlhead(base_url)
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   239
        urls_spec = [(base_url + u'bob0.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   240
                     (base_url + u'bob1.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   241
                     (u'http://ext.com/bob2.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   242
                     (u'http://ext.com/bob3.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   243
                     (base_url + u'bob4.css', 'all'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   244
                     (base_url + u'bob5.css', 'all'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   245
                     (base_url + u'bob6.css', 'print'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   246
                     (base_url + u'bob7.css', 'print'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   247
                     (base_url + u'bob8.css', ('all', u'[if IE 8]')),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   248
                     (base_url + u'bob9.css', ('print', u'[if IE 8]'))
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   249
                     ]
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   250
        result = head.group_urls(urls_spec)
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   251
        expected = [(base_url + u'??bob0.js,bob1.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   252
                    (u'http://ext.com/bob2.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   253
                    (u'http://ext.com/bob3.js', None),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   254
                    (base_url + u'??bob4.css,bob5.css', 'all'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   255
                    (base_url + u'??bob6.css,bob7.css', 'print'),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   256
                    (base_url + u'bob8.css', ('all', u'[if IE 8]')),
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   257
                    (base_url + u'bob9.css', ('print', u'[if IE 8]'))
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   258
                    ]
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   259
        self.assertEqual(list(result), expected)
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   260
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   261
    def test_getvalue_with_concat(self):
9599
13dd3a57dabb [test/utils] repair concat-resources test
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8682
diff changeset
   262
        self.config.global_set_option('concat-resources', True)
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   263
        base_url = u'http://test.fr/data/'
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   264
        head = self.htmlhead(base_url)
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   265
        head.add_js(base_url + u'bob0.js')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   266
        head.add_js(base_url + u'bob1.js')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   267
        head.add_js(u'http://ext.com/bob2.js')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   268
        head.add_js(u'http://ext.com/bob3.js')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   269
        head.add_css(base_url + u'bob4.css')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   270
        head.add_css(base_url + u'bob5.css')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   271
        head.add_css(base_url + u'bob6.css', 'print')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   272
        head.add_css(base_url + u'bob7.css', 'print')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   273
        head.add_ie_css(base_url + u'bob8.css')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   274
        head.add_ie_css(base_url + u'bob9.css', 'print', u'[if lt IE 7]')
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   275
        result = head.getvalue()
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   276
        expected = u"""<head>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   277
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/??bob4.css,bob5.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   278
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/??bob6.css,bob7.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   279
<!--[if lt IE 8]>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   280
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob8.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   281
<!--[if lt IE 7]>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   282
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob9.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   283
<![endif]--> 
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   284
<script type="text/javascript" src="http://test.fr/data/??bob0.js,bob1.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   285
<script type="text/javascript" src="http://ext.com/bob2.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   286
<script type="text/javascript" src="http://ext.com/bob3.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   287
</head>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   288
"""
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   289
        self.assertEqual(result, expected)
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   290
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   291
    def test_getvalue_without_concat(self):
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   292
        self.config.global_set_option('concat-resources', False)
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   293
        try:
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   294
            base_url = u'http://test.fr/data/'
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   295
            head = self.htmlhead(base_url)
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   296
            head.add_js(base_url + u'bob0.js')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   297
            head.add_js(base_url + u'bob1.js')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   298
            head.add_js(u'http://ext.com/bob2.js')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   299
            head.add_js(u'http://ext.com/bob3.js')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   300
            head.add_css(base_url + u'bob4.css')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   301
            head.add_css(base_url + u'bob5.css')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   302
            head.add_css(base_url + u'bob6.css', 'print')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   303
            head.add_css(base_url + u'bob7.css', 'print')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   304
            head.add_ie_css(base_url + u'bob8.css')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   305
            head.add_ie_css(base_url + u'bob9.css', 'print', u'[if lt IE 7]')
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   306
            result = head.getvalue()
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   307
            expected = u"""<head>
7277
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   308
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob4.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   309
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob5.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   310
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob6.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   311
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob7.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   312
<!--[if lt IE 8]>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   313
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob8.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   314
<!--[if lt IE 7]>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   315
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob9.css"/>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   316
<![endif]--> 
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   317
<script type="text/javascript" src="http://test.fr/data/bob0.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   318
<script type="text/javascript" src="http://test.fr/data/bob1.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   319
<script type="text/javascript" src="http://ext.com/bob2.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   320
<script type="text/javascript" src="http://ext.com/bob3.js"></script>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   321
</head>
acd7f0e9f276 [etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents: 6415
diff changeset
   322
"""
7762
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   323
            self.assertEqual(result, expected)
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   324
        finally:
a3f9ba4d44eb [web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7569
diff changeset
   325
            self.config.global_set_option('concat-resources', True)
4890
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4694
diff changeset
   326
11078
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   327
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   328
def load_tests(loader, tests, ignore):
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   329
    import cubicweb.utils
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   330
    tests.addTests(doctest.DocTestSuite(cubicweb.utils))
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   331
    return tests
de4367ef4e5e [test] Use stdlib doctest module instead of logilab-common class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11057
diff changeset
   332
7568
c5ee33fb6a3b [test] run and fix utils and uilib doctests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6415
diff changeset
   333
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   334
if __name__ == '__main__':
11715
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   335
    import unittest
760d5c0ae08f [utils] Encode Binary value in base64 for JSON export
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11714
diff changeset
   336
    unittest.main()