From 8d04c66dc366ee5af8216f98593cc7238f49377e Mon Sep 17 00:00:00 2001
From: Antony Lesuisse <al@openerp.com>
Date: Thu, 1 May 2014 20:42:17 +0200
Subject: [PATCH] [IMP] cleanups, move tests, remove deprecated model
 instantiation

bzr revid: al@openerp.com-20140501184217-pgi1gzbdpysdybog
---
 openerp/addons/base/__openerp__.py            |  6 +-
 openerp/addons/base/ir/ir_default.py          |  2 -
 openerp/addons/base/ir/ir_exports.py          |  2 -
 openerp/addons/base/ir/ir_filters.py          |  2 -
 openerp/addons/base/ir/ir_rule.py             |  3 -
 openerp/addons/base/res/ir_property.py        |  5 --
 openerp/addons/base/res/res_bank.py           |  8 --
 openerp/addons/base/res/res_currency.py       |  6 --
 openerp/addons/base/test/test_auth.yml        | 73 -------------------
 .../addons/base/{test => tests}/base_test.yml |  0
 .../base/{test => tests}/test_ir_rule.yml     |  0
 .../{test => tests}/test_osv_expression.yml   |  0
 12 files changed, 3 insertions(+), 104 deletions(-)
 delete mode 100644 openerp/addons/base/test/test_auth.yml
 rename openerp/addons/base/{test => tests}/base_test.yml (100%)
 rename openerp/addons/base/{test => tests}/test_ir_rule.yml (100%)
 rename openerp/addons/base/{test => tests}/test_osv_expression.yml (100%)

diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py
index d38ac7ceed1b..f5a9ab5a052e 100644
--- a/openerp/addons/base/__openerp__.py
+++ b/openerp/addons/base/__openerp__.py
@@ -93,9 +93,9 @@ The kernel of OpenERP, needed for all installation.
         'res/res_partner_image_demo.xml',
     ],
     'test': [
-        'test/base_test.yml',
-        'test/test_osv_expression.yml',
-        'test/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
+        'tests/base_test.yml',
+        'tests/test_osv_expression.yml',
+        'tests/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
     ],
     'installable': True,
     'auto_install': True,
diff --git a/openerp/addons/base/ir/ir_default.py b/openerp/addons/base/ir/ir_default.py
index 21c66c0972b4..3b82b3aed8ee 100644
--- a/openerp/addons/base/ir/ir_default.py
+++ b/openerp/addons/base/ir/ir_default.py
@@ -43,7 +43,5 @@ class ir_default(osv.osv):
     _defaults = {
         'company_id': _get_company_id,
     }
-ir_default()
-
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/addons/base/ir/ir_exports.py b/openerp/addons/base/ir/ir_exports.py
index 972a21c9047c..c6d188bf02b5 100644
--- a/openerp/addons/base/ir/ir_exports.py
+++ b/openerp/addons/base/ir/ir_exports.py
@@ -31,7 +31,6 @@ class ir_exports(osv.osv):
         'export_fields': fields.one2many('ir.exports.line', 'export_id',
                                          'Export ID'),
     }
-ir_exports()
 
 
 class ir_exports_line(osv.osv):
@@ -41,7 +40,6 @@ class ir_exports_line(osv.osv):
         'name': fields.char('Field Name', size=64),
         'export_id': fields.many2one('ir.exports', 'Export', select=True, ondelete='cascade'),
     }
-ir_exports_line()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
diff --git a/openerp/addons/base/ir/ir_filters.py b/openerp/addons/base/ir/ir_filters.py
index f302fe5c7bfa..418c3073f5e2 100644
--- a/openerp/addons/base/ir/ir_filters.py
+++ b/openerp/addons/base/ir/ir_filters.py
@@ -142,6 +142,4 @@ class ir_filters(osv.osv):
         'is_default': False
     }
 
-ir_filters()
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/addons/base/ir/ir_rule.py b/openerp/addons/base/ir/ir_rule.py
index 9926fd689ac0..96b7da4f5902 100644
--- a/openerp/addons/base/ir/ir_rule.py
+++ b/openerp/addons/base/ir/ir_rule.py
@@ -172,7 +172,4 @@ class ir_rule(osv.osv):
         self.clear_cache(cr,uid)
         return res
 
-ir_rule()
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/openerp/addons/base/res/ir_property.py b/openerp/addons/base/res/ir_property.py
index 2a751361ddc8..543349c78997 100644
--- a/openerp/addons/base/res/ir_property.py
+++ b/openerp/addons/base/res/ir_property.py
@@ -177,9 +177,4 @@ class ir_property(osv.osv):
                   '|', ('company_id', '=', cid), ('company_id', '=', False)]
         return domain
 
-ir_property()
-
-
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/openerp/addons/base/res/res_bank.py b/openerp/addons/base/res/res_bank.py
index 00d18d080788..cc29c50928a2 100644
--- a/openerp/addons/base/res/res_bank.py
+++ b/openerp/addons/base/res/res_bank.py
@@ -51,9 +51,6 @@ class Bank(osv.osv):
             result.append((bank.id, (bank.bic and (bank.bic + ' - ') or '') + bank.name))
         return result
 
-Bank()
-
-
 class res_partner_bank_type(osv.osv):
     _description='Bank Account Type'
     _name = 'res.partner.bank.type'
@@ -67,7 +64,6 @@ class res_partner_bank_type(osv.osv):
     _defaults = {
         'format_layout': lambda *args: "%(bank_name)s: %(acc_number)s"
     }
-res_partner_bank_type()
 
 class res_partner_bank_type_fields(osv.osv):
     _description='Bank type fields'
@@ -80,8 +76,6 @@ class res_partner_bank_type_fields(osv.osv):
         'readonly': fields.boolean('Readonly'),
         'size': fields.integer('Max. Size'),
     }
-res_partner_bank_type_fields()
-
 
 class res_partner_bank(osv.osv):
     '''Bank Accounts'''
@@ -234,6 +228,4 @@ class res_partner_bank(osv.osv):
             result['state_id'] = part.state_id.id
         return {'value': result}
 
-res_partner_bank()
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py
index 194447869353..d92969b564f0 100644
--- a/openerp/addons/base/res/res_currency.py
+++ b/openerp/addons/base/res/res_currency.py
@@ -235,8 +235,6 @@ class res_currency(osv.osv):
             else:
                 return from_amount * rate
 
-res_currency()
-
 class res_currency_rate_type(osv.osv):
     _name = "res.currency.rate.type"
     _description = "Currency Rate Type"
@@ -244,8 +242,6 @@ class res_currency_rate_type(osv.osv):
         'name': fields.char('Name', size=64, required=True, translate=True),
     }
 
-res_currency_rate_type()
-
 class res_currency_rate(osv.osv):
     _name = "res.currency.rate"
     _description = "Currency Rate"
@@ -261,7 +257,5 @@ class res_currency_rate(osv.osv):
     }
     _order = "name desc"
 
-res_currency_rate()
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
diff --git a/openerp/addons/base/test/test_auth.yml b/openerp/addons/base/test/test_auth.yml
deleted file mode 100644
index 62132f01406c..000000000000
--- a/openerp/addons/base/test/test_auth.yml
+++ /dev/null
@@ -1,73 +0,0 @@
--
-  I will now stress the authentication layer of the ORM
--
-  I create a test user.
--
-  !record {model: res.users, id: res_user_test_a1}:
-      name: Test Auth User 1
-      login: test_base_a1
-      password: 'base-test-passwd'
-      active: True
--
-  I will prepare the context
--
-  !python {model: res.users }: |
-    from openerp.tools import config
-    host = config.get_misc('httpd', 'interface')
-    port = config.get_misc('httpd', 'port', 8069)
-    if not host:
-        host = config.get('xmlrpc_interface')
-        port = config.get('xmlrpc_port') or self.port
-    if host == '0.0.0.0' or not host:
-        host = '127.0.0.1'
-    port = int(port)
-    context['test_xmlrpc_url'] = 'http://%s:%d/xmlrpc/' % (host, port)
--
-  I will commit the cursor and try to login.
--
-  !python {model: res.users }: |
-    from xmlrpclib import ServerProxy
-    cr.commit()
-    try:
-        logsock = ServerProxy(context['test_xmlrpc_url']+'common')
-        luid = logsock.login(cr.dbname, 'test_base_a1', 'base-test-passwd')
-        assert luid, "User is not activated after res.users commit!"
-    except Exception:
-        raise
--
-  I will just try to read something as that user
--
-  !python {model: res.users }: |
-    from xmlrpclib import ServerProxy
-    cr.commit()
-    try:
-        logsock = ServerProxy(context['test_xmlrpc_url']+'object')
-        luid = ref('res_user_test_a1')
-        res = logsock.execute(cr.dbname, luid, 'base-test-passwd', 'res.users', 'read', luid, ['name',])
-        assert res and res['name'], "User cannot read its name!"
-    except Exception:
-        raise
--
-  I will now disable the user.
--
-  !record {model: res.users, id: res_user_test_a1}:
-      active: False
--
-  I will commit the cursor.
--
-  !python {model: res.users }: |
-    cr.commit()
--
-  I will try to read again, connecting as the disabled user.
--
-  !python {model: res.users }: |
-    from xmlrpclib import ServerProxy
-    cr.commit()
-    try:
-        logsock = ServerProxy(context['test_xmlrpc_url']+'object')
-        luid = ref('res_user_test_a1')
-        res = logsock.execute(cr.dbname, luid, 'base-test-passwd', 'res.users', 'read', luid, ['name',])
-        raise AssertionError("User should not be enabled!")
-    except Fault, e:
-        if e.faultCode != 'AccessDenied':
-            raise
diff --git a/openerp/addons/base/test/base_test.yml b/openerp/addons/base/tests/base_test.yml
similarity index 100%
rename from openerp/addons/base/test/base_test.yml
rename to openerp/addons/base/tests/base_test.yml
diff --git a/openerp/addons/base/test/test_ir_rule.yml b/openerp/addons/base/tests/test_ir_rule.yml
similarity index 100%
rename from openerp/addons/base/test/test_ir_rule.yml
rename to openerp/addons/base/tests/test_ir_rule.yml
diff --git a/openerp/addons/base/test/test_osv_expression.yml b/openerp/addons/base/tests/test_osv_expression.yml
similarity index 100%
rename from openerp/addons/base/test/test_osv_expression.yml
rename to openerp/addons/base/tests/test_osv_expression.yml
-- 
GitLab