Commit f20d2689 authored by Jérome Perrin's avatar Jérome Perrin

test_result: tolerate buildout section ids with -

parsing of reference in TestResult_getTestSuiteData did not handle
properly buildout section ids with -, this was causing

  File "Script (Python)", line 30, in TestResult_getTestSuiteData
    buildout_section_id_and_commits_count, revision = repository_string.split('-')
  ValueError: too many values to unpack
parent e0679d32
......@@ -27,8 +27,8 @@ test_suite = sorted(
repository_dict = {}
if context.getReference() and '-' in context.getReference(): # tolerate invalid references, especially for tests
for repository_string in context.getReference().split(','):
buildout_section_id_and_commits_count, revision = repository_string.split('-')
buildout_section_id, commits_count = buildout_section_id_and_commits_count.split('=')
buildout_section_id, commits_count_and_revision = repository_string.split('=')
commits_count, revision = commits_count_and_revision.split('-')
repository_dict[buildout_section_id] = {
'revision': revision,
'commits_count': int(commits_count),
......
......@@ -1575,3 +1575,16 @@ class TestGitlabRESTConnectorInterface(ERP5TypeTestCase):
self.test_result.setReference('foo=1-dc7b6e2e85e9434a97694a698884b057b7d30286,test=10-cc4c79c003f7cfe0bfcbc7b302eac988110c96ae')
test_suite_data = self.test_result.TestResult_getTestSuiteData()
self.assertEqual(set(['foo', 'test']), set(test_suite_data['repository_dict']))
# another edge case is when in test suite repository we have a buildout_section_id
# containing a -
self.test_suite.erp5_repo.setBuildoutSectionId('foo-bar')
self.test_result.setReference('foo-bar=1-dc7b6e2e85e9434a97694a698884b057b7d30286,test=10-cc4c79c003f7cfe0bfcbc7b302eac988110c96ae')
test_suite_data = self.test_result.TestResult_getTestSuiteData()
self.assertEqual({
"commits_count": 1,
"connector_relative_url": None,
"repository_url": "https://lab.nexedi.com/nexedi/erp5.git",
"revision": "dc7b6e2e85e9434a97694a698884b057b7d30286",
},
test_suite_data['repository_dict']['foo-bar'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment