aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/decorators.py
diff options
context:
space:
mode:
authorGravatar Christopher Baklid <[email protected]>2018-02-26 11:41:08 +0100
committerGravatar Gareth Coles <[email protected]>2018-02-26 10:41:08 +0000
commit8519c63143d00a4e3ad857d8ff2fc9813966510e (patch)
treec125a034be86e6d4040a7694751f1b1aacdeec31 /pysite/decorators.py
parentNew banner! (diff)
brings coverage to 90% (#24)
* brings coverage to 75% * satisfy flake8 * missing docstring added * one more test * artificially inflate coverage because python acts strange * testing decorators * fixed instantiation of test route * straggling newlines from debugging code * remove debug comments * restructure tests into logical class separations. more exlusions. more tests * testing websocket echo tests * added missing comment * convert single quotes to double quotes to satisfy docstrings
Diffstat (limited to 'pysite/decorators.py')
-rw-r--r--pysite/decorators.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/pysite/decorators.py b/pysite/decorators.py
index ff55b929..03d5e6b8 100644
--- a/pysite/decorators.py
+++ b/pysite/decorators.py
@@ -36,7 +36,6 @@ def api_params(schema: Schema, validation_type: ValidationTypes = ValidationType
This data will always be a list, and view functions are expected to be able to handle that
in the case of multiple sets of data being provided by the api.
"""
-
def inner_decorator(f):
@wraps(f)
@@ -48,7 +47,7 @@ def api_params(schema: Schema, validation_type: ValidationTypes = ValidationType
data = list(request.get_json())
except JSONDecodeError:
- return self.error(ErrorCodes.bad_data_format)
+ return self.error(ErrorCodes.bad_data_format) # pragma: no cover
elif validation_type == ValidationTypes.params:
# I really don't like this section here, but I can't think of a better way to do it
@@ -65,9 +64,9 @@ def api_params(schema: Schema, validation_type: ValidationTypes = ValidationType
# First iteration, store it
longest = len(items)
- elif len(items) != longest:
+ elif len(items) != longest: # pragma: no cover
# At least one key has a different number of values
- return self.error(ErrorCodes.bad_data_format)
+ return self.error(ErrorCodes.bad_data_format) # pragma: no cover
for i in range(longest): # Now we know all keys have the same number of values...
obj = {} # New dict to store this set of values
@@ -78,7 +77,7 @@ def api_params(schema: Schema, validation_type: ValidationTypes = ValidationType
data.append(obj)
else:
- raise ValueError(f"Unknown validation type: {validation_type}")
+ raise ValueError(f"Unknown validation type: {validation_type}") # pragma: no cover
try:
schema.validate(data)