From caa98a09080e1502bb8c817d3c6781c15ee5b038 Mon Sep 17 00:00:00 2001 From: vincent Date: Mon, 21 Jun 2021 22:33:01 +0200 Subject: [PATCH] modifying test client method call --- tests/testBase.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/testBase.py b/tests/testBase.py index d3eb98f..fb4a899 100644 --- a/tests/testBase.py +++ b/tests/testBase.py @@ -1,6 +1,7 @@ import tempfile import unittest import os +from json import loads from ITPlanning.config import DefaultConfig from ITPlanning.db import init_database, release_database from ITPlanning.app import create_app @@ -32,8 +33,13 @@ class APITestBase(TestBase): if not isinstance(args, dict): raise TypeError("'args', expecting a dict, got " + type(args).__name__) uri = "/api/v1/{}".format(endpoint) - method = getattr(self.client, method) - rv = method(uri, data=args, follow_redirects=True) - print(rv.data) + if method == "get": + rv = self.client.get(uri, query_string=args, follow_redirects=True) + if method == "post": + rv = self.client.post(uri, data=args, follow_redirects=True) + if return_code == 200: + data = loads(rv.data) + else: + data = None self.assertEqual(rv.status_code, return_code) - return rv + return rv, data