diff --git a/SW/PC/Stopwatch/config.json b/SW/PC/Stopwatch/config.json index dfe962a..59673ed 100644 --- a/SW/PC/Stopwatch/config.json +++ b/SW/PC/Stopwatch/config.json @@ -1,10 +1,6 @@ { - "url": "https://beta.alkator.cz/api/station/register", "station_id": "1", - "login_url": "https://beta.alkator.cz/api/login", - "racers_url": "https://beta.alkator.cz/api/racers", - "card_register": "https://beta.alkator.cz/api/card/register", - "card_unregister": "https://beta.alkator.cz/api/card/card_unregister", + "host": "https://beta.quarda.cz", "login": "station_register@alkator.cz", "password": "password_heslo" } \ No newline at end of file diff --git a/SW/PC/Stopwatch/main.py b/SW/PC/Stopwatch/main.py index f213418..986e951 100644 --- a/SW/PC/Stopwatch/main.py +++ b/SW/PC/Stopwatch/main.py @@ -28,11 +28,11 @@ with open('config.json', 'r') as f: config = json.load(f) session = requests.Session() -session.post(config['login_url'], {'email':config['login'], 'password': config['password']}) +session.post(config['host'] + '/api/login', {'email':config['login'], 'password': config['password']}) def refreshDb(): global db - resp = session.get(config['racers_url']) + resp = session.get(config['host'] + '/api/racers') if resp.status_code == 200: json = resp.json() db = {} @@ -56,8 +56,8 @@ def sendQueueToSend(): if len(queue_to_send) > 0: to_send = queue_to_send.pop() - response = session.post(config['url'], - to_send, 'application/json' + response = session.post(config['host'] + '/api/station/register', + json=to_send ) if response.status_code != 200: if response.status_code == 400: diff --git a/SW/PC/Stopwatch/registrace.py b/SW/PC/Stopwatch/registrace.py index 948f6a7..ef8dcc1 100644 --- a/SW/PC/Stopwatch/registrace.py +++ b/SW/PC/Stopwatch/registrace.py @@ -19,14 +19,14 @@ with open('config.json', 'r') as f: config = json.load(f) session = requests.Session() -session.post(config['login_url'], {'email':config['login'], 'password': config['password']}) +session.post(config['host'] + '/api/login', {'email':config['login'], 'password': config['password']}) -last_card = 1111 +last_card = 0 last_time = datetime.datetime.now() -response = session.get(config['racers_url']) +response = session.get(config['host'] + '/api/racers') racers = response.json() @@ -40,7 +40,7 @@ def register_racer(): except Exception: raise - response = session.post(config['card_register'], json={'racer_id': racer_id, 'starting_number': starting_number, 'card_id': last_card}) + response = session.post(config['host'] + '/api/card/register', json={'racer_id': racer_id, 'starting_number': starting_number, 'card_id': card_id}) if response.status_code != 200: raise Exception(response.status_code, response.content) @@ -54,9 +54,17 @@ def unregister_racer(): card_id = last_card time = last_time - response = session.post(config['url'], json={'card_id': card_id, 'time': time.strftime('%d.%m.%Y %H:%M:%S.%f'), 'station_id': config['station_id']}) + response = session.post(config['host'] + '/api/station/register', json={'card_id': card_id, 'time': time.strftime('%d.%m.%Y %H:%M:%S.%f'), 'station_id': config['station_id']}) + assert response.status_code == 200 + racer = list(filter(lambda x: x['card_id'] == card_id, racers))[0] + starting_number = racer['starting_number'] + racer_id = racer['racer_id'] + racer['card_id'] = None + response = session.post(config['host'] + '/api/card/unregister', json={'racer_id': racer_id, 'starting_number': starting_number, 'card_id': card_id}) + + assert response.status_code == 200 window = uic.loadUi("registrace.ui")