move tests
move test modules remove xml test add phantomjs test readd remove uninstall test (currently disabled because of cr.commit) bzr revid: al@openerp.com-20140209003745-ehrx8ikwkmusa644
This commit is contained in:
parent
9289a2608d
commit
82372e6a02
|
@ -34,7 +34,4 @@ Importing them from here is deprecated.
|
|||
|
||||
"""
|
||||
|
||||
# get_module_path is used only by base_module_quality
|
||||
from openerp.modules import get_module_resource, get_module_path
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -92,8 +92,6 @@ The kernel of OpenERP, needed for all installation.
|
|||
],
|
||||
'test': [
|
||||
'test/base_test.yml',
|
||||
'test/test_context.xml',
|
||||
'test/bug_lp541545.xml',
|
||||
'test/test_osv_expression.yml',
|
||||
'test/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
|
||||
],
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<!-- Test count attribute for assertions -->
|
||||
<data>
|
||||
<assert
|
||||
model="res.currency.rate"
|
||||
search="[('currency_id', '=', ref('INR'))]"
|
||||
count="1"
|
||||
string="Rate entries for Indian rupee">
|
||||
<test expr="True"/>
|
||||
</assert>
|
||||
</data>
|
||||
|
||||
</openerp>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<!-- Test context attribute for unit tests -->
|
||||
<data context="{'date': '2009-06-01'}">
|
||||
<!-- <assert -->
|
||||
<!-- model="res.currency"-->
|
||||
<!-- id="INR"-->
|
||||
<!-- string="Indian rupee rate in 2009">-->
|
||||
<!-- date specified in data element's context -->
|
||||
<!-- <test expr="str(rate)">65.8287</test>-->
|
||||
<!-- </assert> -->
|
||||
<assert
|
||||
model="res.currency"
|
||||
id="INR"
|
||||
string="Indian rupee rate in 2002"
|
||||
context="{'date': '2010-06-01'}">
|
||||
<test expr="rate_ids and str(rate_ids[0].rate)">59.9739</test>
|
||||
</assert>
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,3 +1,17 @@
|
|||
import test_acl
|
||||
import test_basecase
|
||||
import test_db_cursor
|
||||
import test_expression
|
||||
import test_fields
|
||||
import test_ir_filters
|
||||
import test_ir_sequence
|
||||
import test_mail
|
||||
import test_orm
|
||||
import test_osv
|
||||
import test_translate
|
||||
#import test_uninstall
|
||||
import test_view_validation
|
||||
import test_xmlrpc
|
||||
import test_base
|
||||
import test_expression
|
||||
import test_ir_actions
|
||||
|
@ -8,16 +22,4 @@ import test_res_config
|
|||
import test_res_lang
|
||||
import test_search
|
||||
import test_views
|
||||
|
||||
checks = [
|
||||
test_base,
|
||||
test_expression,
|
||||
test_ir_actions,
|
||||
test_ir_attachment,
|
||||
test_ir_values,
|
||||
test_menu,
|
||||
test_res_config,
|
||||
test_res_lang,
|
||||
test_search,
|
||||
test_views,
|
||||
]
|
||||
import test_phantom
|
||||
|
|
|
@ -3,8 +3,7 @@ from lxml import etree
|
|||
|
||||
import openerp
|
||||
from openerp.tools.misc import mute_logger
|
||||
|
||||
import common
|
||||
from openerp.tests import common
|
||||
|
||||
# test group that demo user should not have
|
||||
GROUP_TECHNICAL_FEATURES = 'base.group_no_one'
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest2
|
||||
|
||||
import common
|
||||
from openerp.tests import common
|
||||
|
||||
class test_single_transaction_case(common.SingleTransactionCase):
|
||||
"""
|
|
@ -4,7 +4,7 @@ import unittest2
|
|||
|
||||
import openerp
|
||||
from openerp.tools.misc import mute_logger
|
||||
import common
|
||||
from openerp.tests import common
|
||||
|
||||
DB = common.DB
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
|
@ -1,8 +1,9 @@
|
|||
import unittest2
|
||||
|
||||
import openerp
|
||||
from openerp.osv.orm import BaseModel
|
||||
import openerp.tests.common as common
|
||||
|
||||
|
||||
class test_expression(common.TransactionCase):
|
||||
|
||||
def _reinit_mock(self):
|
||||
|
@ -439,5 +440,13 @@ class test_expression(common.TransactionCase):
|
|||
partner_parent_id_col._auto_join = False
|
||||
state_country_id_col._auto_join = False
|
||||
|
||||
def test_30_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"
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#
|
||||
# test cases for fields access, etc.
|
||||
#
|
||||
import common
|
||||
|
||||
from openerp.osv import fields
|
||||
from openerp.tests import common
|
||||
|
||||
class TestRelatedField(common.TransactionCase):
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import functools
|
||||
|
||||
from openerp import exceptions
|
||||
from . import common
|
||||
from openerp.tests import common
|
||||
|
||||
def noid(d):
|
||||
""" Removes `id` key from a dict so we don't have to keep these things
|
|
@ -11,7 +11,7 @@ import psycopg2
|
|||
import unittest2
|
||||
|
||||
import openerp
|
||||
import common
|
||||
from openerp.tests import common
|
||||
|
||||
DB = common.DB
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
|
@ -26,9 +26,10 @@ import unittest2
|
|||
|
||||
from lxml import etree
|
||||
|
||||
from openerp.tests import test_mail_examples
|
||||
from openerp.tools import html_sanitize, html_email_clean, append_content_to_html, plaintext2html, email_split
|
||||
|
||||
import test_mail_examples
|
||||
|
||||
|
||||
class TestSanitizer(unittest2.TestCase):
|
||||
""" Test the html sanitizer that filters html to remove unwanted attributes """
|
|
@ -1,13 +1,6 @@
|
|||
# This test can be run stand-alone with something like:
|
||||
# > PYTHONPATH=. python2 openerp/tests/test_misc.py
|
||||
import datetime
|
||||
import locale
|
||||
import unittest2
|
||||
|
||||
import babel
|
||||
import babel.dates
|
||||
|
||||
from ..tools import misc
|
||||
from openerp.tools import misc
|
||||
|
||||
|
||||
class test_countingstream(unittest2.TestCase):
|
|
@ -1,6 +1,6 @@
|
|||
from collections import defaultdict
|
||||
from openerp.tools import mute_logger
|
||||
import common
|
||||
from openerp.tests import common
|
||||
|
||||
UID = common.ADMIN_USER_ID
|
||||
DB = common.DB
|
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openerp
|
||||
from openerp.tests import common
|
||||
|
||||
class test_phantom(common.HttpCase):
|
||||
|
||||
def test_01_dummy(self):
|
||||
self.phantomjs(openerp.modules.module.get_module_resource('base','tests','test_phantom_dummy.js'))
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,4 @@
|
|||
console.log('{ "event": "success", "message": "Phantomjs success"}');
|
||||
// For a failure:
|
||||
// console.log('{ "event": "failure", "message": "The test failed" }');
|
||||
phantom.exit();
|
|
@ -0,0 +1,89 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This assumes an existing but uninitialized database.
|
||||
import unittest2
|
||||
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID
|
||||
import common
|
||||
|
||||
DB = common.DB
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
||||
|
||||
def registry(model):
|
||||
return openerp.modules.registry.RegistryManager.get(DB)[model]
|
||||
|
||||
def cursor():
|
||||
return openerp.modules.registry.RegistryManager.get(DB).db.cursor()
|
||||
|
||||
def get_module(module_name):
|
||||
registry = openerp.modules.registry.RegistryManager.get(DB)
|
||||
return registry.get(module_name)
|
||||
|
||||
def reload_registry():
|
||||
openerp.modules.registry.RegistryManager.new(
|
||||
DB, update_module=True)
|
||||
|
||||
def search_registry(model_name, domain):
|
||||
cr = cursor()
|
||||
model = registry(model_name)
|
||||
record_ids = model.search(cr, SUPERUSER_ID, domain, {})
|
||||
cr.close()
|
||||
return record_ids
|
||||
|
||||
def install_module(module_name):
|
||||
ir_module_module = registry('ir.module.module')
|
||||
cr = cursor()
|
||||
module_ids = ir_module_module.search(cr, SUPERUSER_ID,
|
||||
[('name', '=', module_name)], {})
|
||||
assert len(module_ids) == 1
|
||||
ir_module_module.button_install(cr, SUPERUSER_ID, module_ids, {})
|
||||
cr.commit()
|
||||
cr.close()
|
||||
reload_registry()
|
||||
|
||||
def uninstall_module(module_name):
|
||||
ir_module_module = registry('ir.module.module')
|
||||
cr = cursor()
|
||||
module_ids = ir_module_module.search(cr, SUPERUSER_ID,
|
||||
[('name', '=', module_name)], {})
|
||||
assert len(module_ids) == 1
|
||||
ir_module_module.button_uninstall(cr, SUPERUSER_ID, module_ids, {})
|
||||
cr.commit()
|
||||
cr.close()
|
||||
reload_registry()
|
||||
|
||||
class test_uninstall(unittest2.TestCase):
|
||||
"""
|
||||
Test the install/uninstall of a test module. The module is available in
|
||||
`openerp.tests` which should be present in the addons-path.
|
||||
"""
|
||||
|
||||
def test_01_install(self):
|
||||
""" Check a few things showing the module is installed. """
|
||||
install_module('test_uninstall')
|
||||
assert get_module('test_uninstall.model')
|
||||
|
||||
assert search_registry('ir.model.data',
|
||||
[('module', '=', 'test_uninstall')])
|
||||
|
||||
assert search_registry('ir.model.fields',
|
||||
[('model', '=', 'test_uninstall.model')])
|
||||
|
||||
def test_02_uninstall(self):
|
||||
""" Check a few things showing the module is uninstalled. """
|
||||
uninstall_module('test_uninstall')
|
||||
assert not get_module('test_uninstall.model')
|
||||
|
||||
assert not search_registry('ir.model.data',
|
||||
[('module', '=', 'test_uninstall')])
|
||||
|
||||
assert not search_registry('ir.model.fields',
|
||||
[('model', '=', 'test_uninstall.model')])
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import unittest2
|
||||
import xmlrpclib
|
||||
|
||||
from openerp.tests import common
|
||||
|
||||
DB = common.DB
|
||||
ADMIN_USER = common.ADMIN_USER
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
||||
ADMIN_PASSWORD = common.ADMIN_PASSWORD
|
||||
|
||||
class test_xmlrpc(common.HttpCase):
|
||||
|
||||
def test_01_xmlrpc_login(self):
|
||||
""" Try to login on the common service. """
|
||||
uid = self.xmlrpc_common.login(DB, ADMIN_USER, ADMIN_PASSWORD)
|
||||
self.assertTrue(uid == ADMIN_USER_ID)
|
||||
|
||||
def test_xmlrpc_ir_model_search(self):
|
||||
""" Try a search on the object service. """
|
||||
o = self.xmlrpc_object
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
|
||||
self.assertIsInstance(ids, list)
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
|
||||
self.assertIsInstance(ids, list)
|
||||
|
||||
# This test was written to test the creation of a new RPC endpoint, not
|
||||
# really for the EDI itself.
|
||||
#def test_xmlrpc_import_edi_document(self):
|
||||
# """ Try to call an EDI method. """
|
||||
# msg_re = 'EDI Document is empty!'
|
||||
# with self.assertRaisesRegexp(Exception, msg_re):
|
||||
# self.proxy.edi_60.import_edi_document(DB, ADMIN_USER_ID, ADMIN_PASSWORD, {})
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
@ -282,6 +282,9 @@ class Cursor(object):
|
|||
return self._close(False)
|
||||
|
||||
def _close(self, leak=False):
|
||||
#import traceback
|
||||
#traceback.print_stack()
|
||||
|
||||
if not self._obj:
|
||||
return
|
||||
|
||||
|
|
|
@ -7,43 +7,9 @@ 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 test_acl
|
||||
import test_basecase
|
||||
import test_db_cursor
|
||||
import test_expression
|
||||
import test_fields
|
||||
import test_ir_filters
|
||||
import test_ir_sequence
|
||||
import test_mail
|
||||
import test_misc
|
||||
import test_orm
|
||||
import test_osv
|
||||
import test_translate
|
||||
import test_view_validation
|
||||
import test_qweb
|
||||
import test_func
|
||||
# This need a change in `oe run-tests` to only run fast_suite + checks by default.
|
||||
# import test_xmlrpc
|
||||
|
||||
fast_suite = [
|
||||
test_ir_sequence,
|
||||
test_ir_filters
|
||||
]
|
||||
import common
|
||||
from common import *
|
||||
|
||||
checks = [
|
||||
test_acl,
|
||||
test_expression,
|
||||
test_mail,
|
||||
test_db_cursor,
|
||||
test_orm,
|
||||
test_fields,
|
||||
test_basecase,
|
||||
test_view_validation,
|
||||
test_misc,
|
||||
test_osv,
|
||||
test_translate,
|
||||
test_qweb,
|
||||
test_func,
|
||||
]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -3,15 +3,24 @@
|
|||
The module :mod:`openerp.tests.common` provides a few helpers and classes to write
|
||||
tests.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import select
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
import unittest2
|
||||
import uuid
|
||||
import xmlrpclib
|
||||
import logging
|
||||
|
||||
import openerp
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
# The openerp library is supposed already configured.
|
||||
ADDONS_PATH = openerp.tools.config['addons_path']
|
||||
HOST = '127.0.0.1'
|
||||
PORT = openerp.tools.config['xmlrpc_port']
|
||||
DB = openerp.tools.config['db_name']
|
||||
|
||||
|
@ -22,26 +31,11 @@ DB = openerp.tools.config['db_name']
|
|||
if not DB and hasattr(threading.current_thread(), 'dbname'):
|
||||
DB = threading.current_thread().dbname
|
||||
|
||||
HOST = '127.0.0.1'
|
||||
|
||||
ADMIN_USER = 'admin'
|
||||
ADMIN_USER_ID = openerp.SUPERUSER_ID
|
||||
ADMIN_PASSWORD = 'admin'
|
||||
|
||||
def start_openerp():
|
||||
"""
|
||||
Start the OpenERP server similary to the openerp-server script.
|
||||
"""
|
||||
openerp.service.start_services()
|
||||
|
||||
# Ugly way to ensure the server is listening.
|
||||
time.sleep(2)
|
||||
|
||||
def stop_openerp():
|
||||
"""
|
||||
Shutdown the OpenERP server similarly to a single ctrl-c.
|
||||
"""
|
||||
openerp.service.stop_services()
|
||||
HTTP_SESSION = {}
|
||||
|
||||
class BaseCase(unittest2.TestCase):
|
||||
"""
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Run with one of these commands:
|
||||
# > OPENERP_ADDONS_PATH='../../addons/trunk' OPENERP_PORT=8069 \
|
||||
# OPENERP_DATABASE=yy PYTHONPATH=. python tests/test_xmlrpc.py
|
||||
# > OPENERP_ADDONS_PATH='../../addons/trunk' OPENERP_PORT=8069 \
|
||||
# OPENERP_DATABASE=yy nosetests tests/test_xmlrpc.py
|
||||
# > OPENERP_ADDONS_PATH='../../../addons/trunk' OPENERP_PORT=8069 \
|
||||
# OPENERP_DATABASE=yy PYTHONPATH=../:. unit2 test_xmlrpc
|
||||
import time
|
||||
import unittest2
|
||||
import xmlrpclib
|
||||
|
||||
import common
|
||||
|
||||
DB = None
|
||||
ADMIN_USER = common.ADMIN_USER
|
||||
ADMIN_USER_ID = common.ADMIN_USER_ID
|
||||
ADMIN_PASSWORD = common.ADMIN_PASSWORD
|
||||
|
||||
def setUpModule():
|
||||
common.start_openerp()
|
||||
global DB
|
||||
DB = common.RpcCase.generate_database_name()
|
||||
|
||||
tearDownModule = common.stop_openerp
|
||||
|
||||
class test_xmlrpc(common.RpcCase):
|
||||
|
||||
def test_00_xmlrpc_create_database_polling(self):
|
||||
"""
|
||||
Simulate a OpenERP client requesting the creation of a database and
|
||||
polling the server until the creation is complete.
|
||||
"""
|
||||
progress_id = self.proxy.db_60.create(ADMIN_PASSWORD,DB, True, False,
|
||||
ADMIN_PASSWORD)
|
||||
while True:
|
||||
time.sleep(1)
|
||||
progress, users = self.proxy.db_60.get_progress(ADMIN_PASSWORD,
|
||||
progress_id)
|
||||
if progress == 1.0:
|
||||
break
|
||||
|
||||
def test_xmlrpc_login(self):
|
||||
""" Try to login on the common service. """
|
||||
uid = self.proxy.common_60.login(DB, ADMIN_USER, ADMIN_PASSWORD)
|
||||
assert uid == ADMIN_USER_ID
|
||||
|
||||
def test_xmlrpc_ir_model_search(self):
|
||||
""" Try a search on the object service. """
|
||||
o = self.proxy.object_60
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
|
||||
assert ids
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
|
||||
assert ids
|
||||
|
||||
def test_xmlrpc_8_ir_model_search(self):
|
||||
""" Try a search on the object service. """
|
||||
o = self.proxy.object_8
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [])
|
||||
assert ids
|
||||
ids = o.execute(DB, ADMIN_USER_ID, ADMIN_PASSWORD, 'ir.model', 'search', [], {})
|
||||
assert ids
|
||||
|
||||
# This test was written to test the creation of a new RPC endpoint, not
|
||||
# really for the EDI itself.
|
||||
#def test_xmlrpc_import_edi_document(self):
|
||||
# """ Try to call an EDI method. """
|
||||
# msg_re = 'EDI Document is empty!'
|
||||
# with self.assertRaisesRegexp(Exception, msg_re):
|
||||
# self.proxy.edi_60.import_edi_document(DB, ADMIN_USER_ID, ADMIN_PASSWORD, {})
|
||||
|
||||
def test_zz_xmlrpc_drop_database(self):
|
||||
"""
|
||||
Simulate a OpenERP client requesting the deletion of a database.
|
||||
"""
|
||||
assert self.proxy.db_60.drop(ADMIN_PASSWORD, DB) is True
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -321,7 +321,6 @@ class YamlInterpreter(object):
|
|||
view_info = model.fields_view_get(self.cr, SUPERUSER_ID, varg, 'form', context)
|
||||
|
||||
record_dict = self._create_record(model, fields, view_info, default=default)
|
||||
_logger.debug("RECORD_DICT %s" % record_dict)
|
||||
id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, record.model, \
|
||||
self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode, context=context)
|
||||
self.id_map[record.id] = int(id)
|
||||
|
@ -931,7 +930,7 @@ class YamlInterpreter(object):
|
|||
def yaml_import(cr, module, yamlfile, kind, idref=None, mode='init', noupdate=False, report=None):
|
||||
if idref is None:
|
||||
idref = {}
|
||||
loglevel = logging.INFO if kind == 'test' else logging.DEBUG
|
||||
loglevel = logging.DEBUG
|
||||
yaml_string = yamlfile.read()
|
||||
yaml_interpreter = YamlInterpreter(cr, module, idref, mode, filename=yamlfile.name, report=report, noupdate=noupdate, loglevel=loglevel)
|
||||
yaml_interpreter.process(yaml_string)
|
||||
|
|
Loading…
Reference in New Issue