@@ -451,22 +451,36 @@ def setUp(self):
451451 "web_enterprise" : ["web" ],
452452 }
453453
454- def mock_git_helper (self , repo , cmd ):
455- if repo == self .repo_odoo and cmd == ['show' , 'dfdfcfcf0000ffffffffffffffffffffffffffff:odoo/tests/.runbot/parallel_testing.json' ]:
456- return self .config_file
457- elif repo == self .repo_odoo and cmd == ['show' , 'dfdfcfcf0000ffffffffffffffffffffffffffff:odoo/tests/.runbot/l10n_standalone_testing.json' ]:
458- return self .l10n_standalone_testing_file
459- elif cmd [0 ] == 'show' and cmd [1 ].endswith ('__manifest__.py' ):
460- module = cmd [1 ].split (':' )[- 1 ].split ('/' )[- 2 ]
461- return """{
462- 'name': '%s',
463- 'depends': %s,
464- }""" % (module , self .module_dependencies .get (module , []))
465- elif 'show' in cmd :
454+ def mock_git_helper (self , repo , cmd , input_data = None , raw = False ):
455+ def make_catfile_output (commit , content ):
456+ content_bytes = content .encode ('utf-8' )
457+ header = f"{ commit } blob { len (content_bytes )} \n " .encode ()
458+ result = header + content_bytes + b"\n "
459+ return result
460+
461+ if cmd == ['cat-file' , '--batch' ]:
462+ if repo == self .repo_odoo and input_data == 'dfdfcfcf0000ffffffffffffffffffffffffffff:odoo/tests/.runbot/parallel_testing.json\n ' :
463+ return make_catfile_output ('dfdfcfcf0000ffffffffffffffffffffffffffff' , self .config_file )
464+ if repo == self .repo_odoo and input_data == 'dfdfcfcf0000ffffffffffffffffffffffffffff:odoo/tests/.runbot/l10n_standalone_testing.json\n ' :
465+ return make_catfile_output ('dfdfcfcf0000ffffffffffffffffffffffffffff' , self .l10n_standalone_testing_file )
466+
467+ if "__manifest__.py" in input_data :
468+ modules_info = [
469+ (line , line .split (':' )[- 1 ].split ('/' )[- 2 ])
470+ for line in input_data .splitlines ()
471+ if line .endswith ('__manifest__.py' )
472+ ]
473+ result = b""
474+ for original_query , module in modules_info :
475+ content = '''{'name': '%s', 'depends': %s}''' % (module , self .module_dependencies .get (module , []))
476+ result += make_catfile_output (original_query .split (':' )[0 ], content )
477+ return result
478+
479+ if cmd == ['cat-file' , '--batch' ]:
466480 raise subprocess .CalledProcessError (cmd , 128 )
467481 elif 'diff' in cmd :
468482 return 'odoo/addons/crm/some/file.py\n odoo/addons/project/some/file.py'
469- return super ().mock_git_helper (repo , cmd )
483+ return super ().mock_git_helper (repo , cmd , input_data , raw )
470484
471485 def test_module_filters (self ):
472486 self .assertEqual (self .build ._get_modules_to_test ('-> !mail' ), ['account' , 'base' , 'crm' , 'documents' ])
@@ -859,7 +873,7 @@ def test_modified_existing_module(self):
859873 self .assertEqual (child_dynamic_vars , {
860874 'modified_modules' : 'crm,mail' ,
861875 'test_modules' : 'test_mail' ,
862- 'modules_to_test' : 'crm,mail,test_mail'
876+ 'modules_to_test' : 'crm,mail,test_mail' ,
863877 })
864878
865879 def test_modified_existing_module_parallel (self ):
0 commit comments