From 6fdceab2226b69c1d1b4fd764d390c6bf84fec48 Mon Sep 17 00:00:00 2001 From: Quentin Rendu Date: Mon, 6 Nov 2023 11:41:29 +0100 Subject: [PATCH] Add the option to force pairings in test 9 --- api-webapp/src/test/kotlin/PairingTests.kt | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/api-webapp/src/test/kotlin/PairingTests.kt b/api-webapp/src/test/kotlin/PairingTests.kt index 6cd9286..b19e393 100644 --- a/api-webapp/src/test/kotlin/PairingTests.kt +++ b/api-webapp/src/test/kotlin/PairingTests.kt @@ -246,6 +246,11 @@ class PairingTests: TestBase() { var firstGameID: Int var playersList = mutableListOf() + var forcedPairingList = mutableListOf(1) + var forcedPairing = mutableListOf() + var forcedGames: Json.Array + var game: Json + for (i in 0..34){ playersList.add(players.getJson(i)!!.asObject()["id"] as Long) } @@ -254,12 +259,25 @@ class PairingTests: TestBase() { for (round in 1..7) { //games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array(playersList.filter{it != byePlayerList[round-1]})).asArray() - games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array("all")).asArray() - logger.info("games for round $round: {}", games.toString()) - assertTrue(compare_weights("weights.txt", "opengotha/notsosimpleswiss_weights_R$round.txt"), "Not matching opengotha weights for round $round") - assertTrue(compare_games(games, Json.parse(pairings[round - 1])!!.asArray()),"pairings for round $round differ") - logger.info("Pairings for round $round match OpenGotha") + if (round in forcedPairingList){ + forcedPairing = mutableListOf() + forcedGames = Json.parse(pairingsR1)!!.asArray() + for (j in 0..forcedGames.size-1) { + game = forcedGames.getJson(j)!!.asObject() + forcedPairing.add(TestAPI.post("/api/tour/$id/pair/$round", Json.Array(listOf(game["w"],game["b"]))).asArray().getJson(0)!!) + } + games = Json.Array(forcedPairing) + } + else { + games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array("all")).asArray() + logger.info("games for round $round: {}", games.toString()) + + assertTrue(compare_weights("weights.txt", "opengotha/notsosimpleswiss_weights_R$round.txt"), "Not matching opengotha weights for round $round") + assertTrue(compare_games(games, Json.parse(pairings[round - 1])!!.asArray()),"pairings for round $round differ") + logger.info("Pairings for round $round match OpenGotha") + } + logger.info("games for round $round: {}", games.toString()) firstGameID = (games.getJson(0)!!.asObject()["id"] as Long?)!!.toInt() for (gameID in firstGameID..firstGameID + 15) {