def test_Tournement(self): assert Tournament.Insert(sport_test.randomString(self), "overcooked", "2020-01-0714:30:00") with pytest.raises(turnamentError) as context: result = Tournament.Insert(sport_test.randomString(self), "null", "2020-01-0714:30:00") print(str(context.value))
def callback(ch, method, properties, body): print(" [x] Received %r" % body) output_json = json.loads(body) # add title print('add title') print(output_json["data"]["title"], output_json["data"]["date_start_text"]) Title.Insert(output_json["data"]["title"], output_json["data"]["state"]) # add tournamte trnmt = "" print('add tournamte', output_json["data"]["title"]) tmp = output_json["data"]["tournament"] if len(tmp) == 2: print(tmp["name"]) Tournament.Insert(tmp["name"], output_json["data"]["title"], output_json["data"]["date_start_text"]) trnmt = tmp["name"] else: print(output_json["data"]["tournament"]) Tournament.Insert(output_json["data"]["tournament"], output_json["data"]["title"], output_json["data"]["date_start_text"]) trnmt = output_json["data"]["tournament"] # add team print('add team') for tmp in output_json["data"]["teams"]: Team.Insert(tmp["id"], tmp["name"]) print(tmp["id"], tmp["name"]) # add Matches print('add matches') print(output_json["data"]["scores"][0]["team"]) print(output_json["data"]["scores"][1]["team"]) Matches.Insert(trnmt, output_json["data"]["scores"][0]["team"], output_json["data"]["scores"][1]["team"]) # add Score print('add Score') # Insert(_Tournament, _Team,_Score,_winner,_Team1,_Team2) Scores.Insert(trnmt, output_json["data"]["scores"][0]["team"], output_json["data"]["scores"][0]["score"], output_json["data"]["scores"][0]["winner"], output_json["data"]["scores"][0]["team"], output_json["data"]["scores"][1]["team"]) Scores.Insert(trnmt, output_json["data"]["scores"][1]["team"], output_json["data"]["scores"][1]["score"], output_json["data"]["scores"][1]["winner"], output_json["data"]["scores"][0]["team"], output_json["data"]["scores"][1]["team"])