Skip to content

Commit

Permalink
Error message for empty workflow file (#809) (#833)
Browse files Browse the repository at this point in the history
fixes #809
  • Loading branch information
nicolecastillo committed May 19, 2020
1 parent 5e17323 commit e739b60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/popper/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def parse(

with open(file, "r") as f:
_wf_data = yaml.safe_load(f)

if not _wf_data:
log.fail(f"File {file} is empty")
else:
_wf_data = wf_data

Expand Down
11 changes: 11 additions & 0 deletions cli/test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ def setUp(self):
def tearDown(self):
log.setLevel("NOTSET")

def test_empty_file(self):
try:
f = open("test.yml", "a")
f.close()
WorkflowParser.parse(file="test.yml")
self.assertTrue(False, "Empty Workflow file does not raise an exception.")
except SystemExit:
self.assertTrue(True)
else:
self.assertTrue(False, "Empty Workflow file does not raise a SystemExit.")

def test_new_workflow(self):
wf_data = {}
self.assertRaises(SystemExit, WorkflowParser.parse, **{"wf_data": wf_data})
Expand Down

0 comments on commit e739b60

Please sign in to comment.