Skip to content

Commit

Permalink
Merge pull request #156 from gisce/allow_test_depends_for_modules
Browse files Browse the repository at this point in the history
Allow extra module dependencies to be installed on tests
  • Loading branch information
polsala authored Nov 8, 2024
2 parents 9acb5e5 + 9093e44 commit 8b8031a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion destral/openerp.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def db_name(self, value):
self.db = None
self.pool = None

def install_module(self, module):
def install_module(self, module, with_test_depends=False):
"""Installs a module
:param module: Module to install
Expand All @@ -138,6 +138,20 @@ def install_module(self, module):
[('name', '=', module)],
)
assert module_ids, "Module %s not found" % module
module_info = module_obj.get_module_info(module)
if with_test_depends and module_info.get('test_depends'):
logger.info("Found extra dependencies for module %s" % module)
extra_modules = module_info['test_depends']
logger.info("Including extra dependencies:\n%s" % '\n'.join(extra_modules))
extra_modules_ids = module_obj.search(
txn.cursor, DEFAULT_USER,
[('name', 'in', extra_modules), ('state', '!=', 'installed')],
)
if len(extra_modules_ids) != len(extra_modules):
logger.warning("Some extra dependencies were not found or already installed")

module_ids.extend(extra_modules_ids)

module_obj.button_install(cursor, uid, module_ids)
pool = pooler.get_pool(cursor.dbname)
mod_obj = pool.get('ir.module.module')
Expand Down
2 changes: 1 addition & 1 deletion destral/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run(self, result, debug=False):
else:
self.drop_database = False
result.db_name = self.openerp.db_name
self.openerp.install_module(self.config['module'])
self.openerp.install_module(self.config['module'], with_test_depends=True)
else:
self.openerp.db_name = result.db_name

Expand Down

0 comments on commit 8b8031a

Please sign in to comment.