summaryrefslogtreecommitdiff
path: root/migration-test/apitest/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'migration-test/apitest/api.py')
-rw-r--r--migration-test/apitest/api.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/migration-test/apitest/api.py b/migration-test/apitest/api.py
new file mode 100644
index 0000000..cd34844
--- /dev/null
+++ b/migration-test/apitest/api.py
@@ -0,0 +1,49 @@
+import json
+import urlparse
+
+from .apitest import ApiTest
+
+class ApiCalculator(ApiTest):
+ ranks = {
+ 'kmp': 101,
+ 'o++++': 7,
+ 'o+++': 6,
+ 'o++': 5,
+ 'o+': 4,
+ 'o-': 3,
+ 'r': 2,
+ 'o': 1,
+ 'k': 0
+ }
+ def get_url(self):
+ return 'http://pzbs.pl/sedziowie/pkl/api.php'
+ def get_method(self):
+ return 'post'
+ def get_request(self,
+ tour_type, tour_rank, tour_boards,
+ cont_count, cont_rank,
+ override=None):
+ params = {}
+ #params['version'] = '1'
+ params['type'] = self.tourtypes[tour_type]
+ params['over39_boards'] = tour_boards
+ params['tournament_rank'] = self.ranks[tour_rank]
+ params['contestants'] = cont_count
+ params['title_sum'] = cont_rank
+ if override:
+ if 'points' in override:
+ params['manual[min_points]'] = override['points']
+ if 'weight' in override:
+ params['manual[tournament_weight]'] = override['weight']
+ if 'players' in override:
+ params['manual[players_coefficient]'] = override['players']
+ if 'cutoff' in override:
+ i = 0
+ for c in override['cutoff']:
+ params['manual[points_cutoffs][' + str(i) + '][0]'] = c[0]
+ params['manual[points_cutoffs][' + str(i) + '][1]'] = c[1]
+ i += 1
+ return params
+
+ def get_response(self, text):
+ return json.loads(text)