Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema docs #74

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() == False
self.assertTrue(captured[0][0].msg == "Input file is not valid.")