modifying test client method call
This commit is contained in:
parent
d0a0627468
commit
caa98a0908
@ -1,6 +1,7 @@
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
|
from json import loads
|
||||||
from ITPlanning.config import DefaultConfig
|
from ITPlanning.config import DefaultConfig
|
||||||
from ITPlanning.db import init_database, release_database
|
from ITPlanning.db import init_database, release_database
|
||||||
from ITPlanning.app import create_app
|
from ITPlanning.app import create_app
|
||||||
@ -32,8 +33,13 @@ class APITestBase(TestBase):
|
|||||||
if not isinstance(args, dict):
|
if not isinstance(args, dict):
|
||||||
raise TypeError("'args', expecting a dict, got " + type(args).__name__)
|
raise TypeError("'args', expecting a dict, got " + type(args).__name__)
|
||||||
uri = "/api/v1/{}".format(endpoint)
|
uri = "/api/v1/{}".format(endpoint)
|
||||||
method = getattr(self.client, method)
|
if method == "get":
|
||||||
rv = method(uri, data=args, follow_redirects=True)
|
rv = self.client.get(uri, query_string=args, follow_redirects=True)
|
||||||
print(rv.data)
|
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)
|
self.assertEqual(rv.status_code, return_code)
|
||||||
return rv
|
return rv, data
|
||||||
|
Loading…
Reference in New Issue
Block a user