[IMP] move test cases to tests.py remove deprecated wsgi import
bzr revid: al@openerp.com-20140209151822-cgk0wibqe1kfd42w
This commit is contained in:
parent
ac68581e2e
commit
e6ac29ee43
|
@ -19,17 +19,27 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
""" OpenERP core library..
|
""" OpenERP core library."""
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
# Running mode flags (gevent, prefork)
|
||||||
|
#----------------------------------------------------------
|
||||||
# Is the server running with gevent.
|
# Is the server running with gevent.
|
||||||
|
import sys
|
||||||
evented = False
|
evented = False
|
||||||
if sys.modules.get("gevent") is not None:
|
if sys.modules.get("gevent") is not None:
|
||||||
evented = True
|
evented = True
|
||||||
|
|
||||||
|
# Is the server running in pefork mode (e.g. behind Gunicorn).
|
||||||
|
# If this is True, the processes have to communicate some events,
|
||||||
|
# e.g. database update or cache invalidation. Each process has also
|
||||||
|
# its own copy of the data structure and we don't need to care about
|
||||||
|
# locks between threads.
|
||||||
|
multi_process = False
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
# libc UTC hack
|
||||||
|
#----------------------------------------------------------
|
||||||
# Make sure the OpenERP server runs in UTC. This is especially necessary
|
# Make sure the OpenERP server runs in UTC. This is especially necessary
|
||||||
# under Windows as under Linux it seems the real import of time is
|
# under Windows as under Linux it seems the real import of time is
|
||||||
# sufficiently deferred so that setting the TZ environment variable
|
# sufficiently deferred so that setting the TZ environment variable
|
||||||
|
@ -40,9 +50,22 @@ import time # ... *then* import time.
|
||||||
del os
|
del os
|
||||||
del time
|
del time
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
# Shortcuts
|
||||||
|
#----------------------------------------------------------
|
||||||
# The hard-coded super-user id (a.k.a. administrator, or root user).
|
# The hard-coded super-user id (a.k.a. administrator, or root user).
|
||||||
SUPERUSER_ID = 1
|
SUPERUSER_ID = 1
|
||||||
|
|
||||||
|
def registry(database_name):
|
||||||
|
"""
|
||||||
|
Return the model registry for the given database. If the registry does not
|
||||||
|
exist yet, it is created on the fly.
|
||||||
|
"""
|
||||||
|
return modules.registry.RegistryManager.get(database_name)
|
||||||
|
|
||||||
|
#----------------------------------------------------------
|
||||||
|
# Imports
|
||||||
|
#----------------------------------------------------------
|
||||||
import addons
|
import addons
|
||||||
import cli
|
import cli
|
||||||
import conf
|
import conf
|
||||||
|
@ -58,23 +81,6 @@ import service
|
||||||
import sql_db
|
import sql_db
|
||||||
import tools
|
import tools
|
||||||
import workflow
|
import workflow
|
||||||
# backward compatilbility
|
|
||||||
# TODO: This is for the web addons, can be removed later.
|
|
||||||
wsgi = service
|
|
||||||
wsgi.register_wsgi_handler = wsgi.wsgi_server.register_wsgi_handler
|
|
||||||
# Is the server running in multi-process mode (e.g. behind Gunicorn).
|
|
||||||
# If this is True, the processes have to communicate some events,
|
|
||||||
# e.g. database update or cache invalidation. Each process has also
|
|
||||||
# its own copy of the data structure and we don't need to care about
|
|
||||||
# locks between threads.
|
|
||||||
multi_process = False
|
|
||||||
|
|
||||||
def registry(database_name):
|
|
||||||
"""
|
|
||||||
Return the model registry for the given database. If the registry does not
|
|
||||||
exist yet, it is created on the fly.
|
|
||||||
"""
|
|
||||||
return modules.registry.RegistryManager.get(database_name)
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -1181,6 +1181,6 @@ root = None
|
||||||
def wsgi_postload():
|
def wsgi_postload():
|
||||||
global root
|
global root
|
||||||
root = Root()
|
root = Root()
|
||||||
openerp.wsgi.register_wsgi_handler(root)
|
openerp.service.wsgi_server.register_wsgi_handler(root)
|
||||||
|
|
||||||
# vim:et:ts=4:sw=4:
|
# vim:et:ts=4:sw=4:
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
The module :mod:`openerp.tests.common` provides a few helpers and classes to write
|
The module :mod:`openerp.tests.common` provides unittest2 test cases and a few
|
||||||
tests.
|
helpers and classes to write tests.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -13,8 +14,11 @@ import unittest2
|
||||||
import uuid
|
import uuid
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
|
# backward compatbility
|
||||||
|
common = sys.modules['openerp.tests.common'] = sys.modules['openerp.tests']
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Tests for the OpenERP library.
|
|
||||||
|
|
||||||
This module groups a few sub-modules containing unittest2 test cases.
|
|
||||||
|
|
||||||
Tests can be explicitely added to the `fast_suite` or `checks` lists or not.
|
|
||||||
See the :ref:`test-framework` section in the :ref:`features` list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import common
|
|
||||||
from common import *
|
|
||||||
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
@ -1,13 +0,0 @@
|
||||||
import unittest2
|
|
||||||
|
|
||||||
import openerp
|
|
||||||
|
|
||||||
|
|
||||||
class test_domain_normalization(unittest2.TestCase):
|
|
||||||
def test_normalize_domain(self):
|
|
||||||
expression = openerp.osv.expression
|
|
||||||
norm_domain = domain = ['&', (1, '=', 1), ('a', '=', 'b')]
|
|
||||||
assert norm_domain == expression.normalize_domain(domain), "Normalized domains should be left untouched"
|
|
||||||
domain = [('x', 'in', ['y', 'z']), ('a.v', '=', 'e'), '|', '|', ('a', '=', 'b'), '!', ('c', '>', 'd'), ('e', '!=', 'f'), ('g', '=', 'h')]
|
|
||||||
norm_domain = ['&', '&', '&'] + domain
|
|
||||||
assert norm_domain == expression.normalize_domain(domain), "Non-normalized domains should be properly normalized"
|
|
Loading…
Reference in New Issue