Skip to content

Commit b536c64

Browse files
committed
Fixed #199
Missing version value will not treat as a warning instead of error.
1 parent d6a10e2 commit b536c64

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

about_code_tool/about.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,14 @@ def validate_field_values_are_not_empty(self):
428428
continue
429429

430430
if field_name in MANDATORY_FIELDS:
431-
err = Error(VALUE, field_name, None,
432-
'This mandatory field has no value.')
433-
self.errors.append(err)
431+
if field_name == 'version':
432+
err = Warn(VALUE, field_name, None,
433+
'This mandatory field has no value.')
434+
self.warnings.append(err)
435+
else:
436+
err = Error(VALUE, field_name, None,
437+
'This mandatory field has no value.')
438+
self.errors.append(err)
434439
elif field_name in OPTIONAL_FIELDS:
435440
err = Warn(VALUE, field_name, None,
436441
'This optional field has no value.')
@@ -517,8 +522,12 @@ def validate_mandatory_fields_are_present(self):
517522
"""
518523
for field_name in MANDATORY_FIELDS:
519524
if field_name not in self.validated_fields:
520-
self.errors.append(Error(VALUE, field_name, None,
525+
if field_name == 'version' :
526+
self.warnings.append(Error(VALUE, field_name, None,
521527
'Mandatory field missing'))
528+
else:
529+
self.errors.append(Error(VALUE, field_name, None,
530+
'Mandatory field missing'))
522531

523532
def validate_known_optional_fields(self, field_name):
524533
"""

about_code_tool/tests/test_about.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,28 @@ def test_validate_about_resource_error_thrown_when_file_referenced_by_about_file
365365

366366
def test_validate_mand_fields_name_and_version_and_about_resource_present(self):
367367
about_file = AboutFile(join(TESTDATA_DIR, 'parser_tests/missing_mand.ABOUT'))
368-
expected_errors = [(VALUE, 'name'),
369-
(VALUE, 'version'), ]
370-
self.assertEqual(2, len(about_file.errors))
368+
expected_errors = [(VALUE, 'name'),]
369+
expected_warnings = [(VALUE, 'version'),]
370+
self.assertEqual(1, len(about_file.errors))
371+
self.assertEqual(1, len(about_file.warnings))
371372
for i, w in enumerate(about_file.errors):
372373
self.assertEqual(expected_errors[i][0], w.code)
373374
self.assertEqual(expected_errors[i][1], w.field_name)
375+
for i, w in enumerate(about_file.warnings):
376+
self.assertEqual(expected_warnings[i][0], w.code)
377+
self.assertEqual(expected_warnings[i][1], w.field_name)
374378

375379
about_file = AboutFile(join(TESTDATA_DIR, 'parser_tests/missing_mand_values.ABOUT'))
376-
expected_errors = [(VALUE, 'name'),
377-
(VALUE, 'version')]
378-
self.assertEqual(2, len(about_file.errors))
380+
expected_errors = [(VALUE, 'name'),]
381+
expected_warnings = [(VALUE, 'version'),]
382+
self.assertEqual(1, len(about_file.errors))
383+
self.assertEqual(1, len(about_file.warnings))
379384
for i, w in enumerate(about_file.errors):
380385
self.assertEqual(expected_errors[i][0], w.code)
381386
self.assertEqual(expected_errors[i][1], w.field_name)
387+
for i, w in enumerate(about_file.warnings):
388+
self.assertEqual(expected_warnings[i][0], w.code)
389+
self.assertEqual(expected_warnings[i][1], w.field_name)
382390

383391
def test_validate_optional_file_field_value(self):
384392
about_file = AboutFile(join(TESTDATA_DIR, 'parser_tests/about_file_ref.c.ABOUT'))

about_code_tool/tests/test_genabout.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ def test_verify_files_existence_exist(self):
574574
result = gen.verify_files_existence(input_list=test_fields,
575575
project_dir=gen_location,
576576
file_in_project=False)
577-
print(result)
578577
self.assertEqual(expected, result)
579578
self.assertFalse(gen.warnings, 'No warnings should be returned.')
580579
self.assertFalse(gen.errors, 'No errors should be returned.')
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
download_url: http://archive.apache.org/dist/httpd/httpd-2.4.3.tar.gz
22
date: 2012-08-21
33
license_spdx: Apache-2.0
4-
license_text_file: httpd.LICENSE
5-
copyright: Copyright 2012 The Apache Software Foundation.
6-
notice_file: httpd.NOTICE
4+
copyright: Copyright 2012 The Apache Software Foundation.
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name:
2-
about_resource:
32
download_url: http://archive.apache.org/dist/httpd/httpd-2.4.3.tar.gz
43
version:
54
date: 2012-08-21
65
license_spdx: Apache-2.0
7-
license_text_file: httpd.LICENSE
8-
copyright: Copyright 2012 The Apache Software Foundation.
9-
notice_file: httpd.NOTICE
6+
copyright: Copyright 2012 The Apache Software Foundation.

0 commit comments

Comments
 (0)