Skip to content

Commit

Permalink
Add schema docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
lymereJ committed Oct 27, 2023
1 parent a7af978 commit 5da064d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion copper/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ def __init__(self, input):
self.validator = Validator(self.schema, resolver=self.resolver)

def validate(self):
"""Validate input file to be used in the CLI.
:return: Result of the validation
:rtype: bool
"""
try:
self.validator.validate(self.input)
return True
except:
logging.critical("Input file is not valid.")
return
return False
5 changes: 5 additions & 0 deletions docs/source/Code Documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ Code Documentation
:inherited-members:
:undoc-members:
:show-inheritance:
.. automodule:: copper.schema
:members:
:inherited-members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def test_bad_schema(self):
input_file = json.load(open("./tests/data/cli_input_file.json", "r"))
input_file["actions"][0]["function_call"]["vars"] = 42.0
with self.assertLogs() as captured:
assert cp.Schema(input=input_file).validate() is None
assert cp.Schema(input=input_file).validate()
self.assertTrue(captured[0][0].msg == "Input file is not valid.")

0 comments on commit 5da064d

Please sign in to comment.