summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-05-13 18:18:44 +0200
committeremkael <emkael@tlen.pl>2020-05-13 18:18:44 +0200
commit761510c4675dd5817c432d1f71c4698dd42ec77e (patch)
tree3f2e4cde64f4a6054d690667a1fcfd1c221475e4
parentb39ecaf33e421e7dd61cfd701002d1f1cb0e9c3f (diff)
Using migration tests to generate random unit test cases
-rw-r--r--migration-test/apitest/api.py3
-rw-r--r--migration-test/tests/ApiTest.py54
2 files changed, 34 insertions, 23 deletions
diff --git a/migration-test/apitest/api.py b/migration-test/apitest/api.py
index 5fa2e4b..cd34844 100644
--- a/migration-test/apitest/api.py
+++ b/migration-test/apitest/api.py
@@ -5,6 +5,7 @@ from .apitest import ApiTest
class ApiCalculator(ApiTest):
ranks = {
+ 'kmp': 101,
'o++++': 7,
'o+++': 6,
'o++': 5,
@@ -23,7 +24,7 @@ class ApiCalculator(ApiTest):
cont_count, cont_rank,
override=None):
params = {}
- params['version'] = '1'
+ #params['version'] = '1'
params['type'] = self.tourtypes[tour_type]
params['over39_boards'] = tour_boards
params['tournament_rank'] = self.ranks[tour_rank]
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))