From 8519c63143d00a4e3ad857d8ff2fc9813966510e Mon Sep 17 00:00:00 2001 From: Christopher Baklid Date: Mon, 26 Feb 2018 11:41:08 +0100 Subject: 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 --- pysite/decorators.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pysite/decorators.py') 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) -- cgit v1.2.3