diff options
author | emkael <emkael@tlen.pl> | 2020-05-13 18:18:44 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2020-05-13 18:18:44 +0200 |
commit | 761510c4675dd5817c432d1f71c4698dd42ec77e (patch) | |
tree | 3f2e4cde64f4a6054d690667a1fcfd1c221475e4 /migration-test/tests/ApiTest.py | |
parent | b39ecaf33e421e7dd61cfd701002d1f1cb0e9c3f (diff) |
Using migration tests to generate random unit test cases
Diffstat (limited to 'migration-test/tests/ApiTest.py')
-rw-r--r-- | migration-test/tests/ApiTest.py | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/migration-test/tests/ApiTest.py b/migration-test/tests/ApiTest.py index 0af8626..72ecf7f 100644 --- a/migration-test/tests/ApiTest.py +++ b/migration-test/tests/ApiTest.py @@ -1,4 +1,5 @@ import csv +import json import requests import random import os @@ -8,11 +9,15 @@ from apitest.pzbs import PzbsCalculator from apitest.api import ApiCalculator def runTest(tester, params): - return tester.get_response( + request=tester.get_request(*params) + response=tester.get_response( requests.post( tester.get_url(), - data=tester.get_request(*params) + data=request ).text) + print json.dumps(request) + print json.dumps(response) + return response class ApiTestCase(unittest.TestCase): def __setupParams(self): @@ -54,10 +59,11 @@ class ApiTestCase(unittest.TestCase): p = (type, rank, boards, random.randint(6, 350), random.randint(0, 4000) / 2.0) - self.assertEqual( - runTest(self.pzbs, p), - runTest(self.api, p), - msg=str(p)) + runTest(self.api, p) + #self.assertEqual( + # runTest(self.pzbs, p), + # runTest(self.api, p), + # msg=str(p)) def test_customParamCases(self): for type in ['t', 'p', 'i']: @@ -69,30 +75,33 @@ class ApiTestCase(unittest.TestCase): } p = (type, rank, boards, 35, 400, manualParams) - self.assertEqual( - runTest(self.pzbs, p), - runTest(self.api, p), - msg=str(p)) + runTest(self.api, p) + #self.assertEqual( + # runTest(self.pzbs, p), + # runTest(self.api, p), + # msg=str(p)) for j in range(0, 20): manualParams = { 'weight': random.randint(20, 100) } p = (type, rank, boards, 35, 400, manualParams) - self.assertEqual( - runTest(self.pzbs, p), - runTest(self.api, p), - msg=str(p)) + runTest(self.api, p) + #self.assertEqual( + # runTest(self.pzbs, p), + # runTest(self.api, p), + # msg=str(p)) for j in range(0, 20): manualParams = { 'players': random.randint(20, 100) * 0.001 } p = (type, rank, boards, 35, 400, manualParams) - self.assertEqual( - runTest(self.pzbs, p), - runTest(self.api, p), - msg=str(p)) + runTest(self.api, p) + #self.assertEqual( + # runTest(self.pzbs, p), + # runTest(self.api, p), + # msg=str(p)) for j in range(0, 20): manualParams = { 'cutoff': [ @@ -108,7 +117,8 @@ class ApiTestCase(unittest.TestCase): random.randint(20, 25), random.randint(300, 400) / 2.0, manualParams) - self.assertEqual( - runTest(self.pzbs, p), - runTest(self.api, p), - msg=str(p)) + runTest(self.api, p) + #self.assertEqual( + # runTest(self.pzbs, p), + # runTest(self.api, p), + # msg=str(p)) |