Skip to content

Commit

Permalink
Merge pull request #11 from usdot-jpo-ode/check-config-file-exists
Browse files Browse the repository at this point in the history
Assert config file exists to prevent empty validations errors
  • Loading branch information
mvs5465 authored Apr 3, 2019
2 parents a34fb82 + 9b5b255 commit f212971
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions odevalidator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import logging
from decimal import Decimal
from pathlib import Path
import queue
from result import ValidationResult, ValidatorException
from sequential import Sequential
Expand Down Expand Up @@ -80,6 +81,7 @@ def validate(self, data):

class TestCase:
def __init__(self, filepath):
assert Path(filepath).is_file(), "Configuration file '%s' could not be found" % filepath
self.config = configparser.ConfigParser()
self.config.read(filepath)
self.field_list = []
Expand Down Expand Up @@ -155,14 +157,14 @@ def test_file(validator, data_file):
content = f.readlines()

# remove whitespace characters like `\n` at the end of each line
content = [x.strip() for x in content]
content = [x.strip() for x in content]
#msgs = [json.loads(line) for line in content]

q = queue.Queue()
for msg in content:
q.put(msg)

results = validator.validate_queue(q)
results = validator.validate_queue(q)

return results

Expand Down

0 comments on commit f212971

Please sign in to comment.