Skip to content

Commit

Permalink
Fixed #67
Browse files Browse the repository at this point in the history
Add code/test code for handling blank line
  • Loading branch information
chinyeungli committed Jan 20, 2014
1 parent 555d8f3 commit e943297
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 12 additions & 4 deletions about_code_tool/genabout.py
Expand Up @@ -118,17 +118,25 @@ def read_input(self, input_file, mapping):
if not version == 'version':
del line[version]
if not line['about_file']:
missing_about_file = "'about_file' field value is missing. Generation is skipped."
self.errors.append(Error('about_file', None, missing_about_file))
# This code is to handle blank line
for key in line.keys():
if line[key]:
missing_about_file = "'about_file' field value is missing. Generation is skipped."
self.errors.append(Error('about_file', None, missing_about_file))
break
continue
except Exception as e:
print(repr(e))
print("The input does not have the 'about_file' key which is required.")
sys.exit(errno.EINVAL)
try:
if not line['about_resource']:
missing_about_resource = "'about_resource' is missing. Generation is skipped."
self.errors.append(Error('about_resource', line['about_file'], missing_about_resource))
# This code is to handle blank line
for key in line.keys():
if line[key]:
missing_about_resource = "'about_resource' is missing. Generation is skipped."
self.errors.append(Error('about_resource', line['about_file'], missing_about_resource))
break
continue
except Exception as e:
print(repr(e))
Expand Down
6 changes: 6 additions & 0 deletions about_code_tool/tests/test_genabout.py
Expand Up @@ -35,6 +35,12 @@ def test_read_input(self):
list = gen.read_input(test_input, False)
self.assertTrue(list, "List shouldn't be empty.")

def test_read_input_with_blank_line(self):
gen = genabout.GenAbout()
test_input = join(TESTDATA_PATH, "test_files_for_genabout/contains_blank_line.csv")
list = gen.read_input(test_input, False)
self.assertTrue(list, "List shouldn't be empty.")

def test_read_input_missing_about_file(self):
gen = genabout.GenAbout()
test_input = join(TESTDATA_PATH, "test_files_for_genabout/missing_about_file.csv")
Expand Down
@@ -0,0 +1,5 @@
about_file,about_resource,name,version
test_blank line,/tmp/,blank line,0.8.1
blank line below,/tmp/1/,,
,,,
blank line above,/tmp/2/,,

0 comments on commit e943297

Please sign in to comment.