Correct result entered for basic MMS test
This commit is contained in:
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.TestInstance
|
||||
import org.junit.jupiter.api.TestMethodOrder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.math.abs
|
||||
import kotlin.reflect.typeOf
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@@ -344,20 +345,30 @@ class PairingTests: TestBase() {
|
||||
|
||||
var games: Json.Array
|
||||
var firstGameID: Int
|
||||
var forcedGames: Json.Array
|
||||
var game: Json
|
||||
|
||||
for (round in 1..5) {
|
||||
// games must be created and then modified by PUT
|
||||
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/simplemm/simplemm_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("Weights for round $round match OpenGotha")
|
||||
|
||||
forcedGames = Json.parse(pairings[round-1])!!.asArray()
|
||||
for (j in 0..forcedGames.size-1) {
|
||||
game = forcedGames.getJson(j)!!.asObject()
|
||||
TestAPI.put("/api/tour/$id/pair/$round", game)
|
||||
}
|
||||
|
||||
// Enter results
|
||||
firstGameID = (games.getJson(0)!!.asObject()["id"] as Long?)!!.toInt()
|
||||
for (gameID in firstGameID..firstGameID + 15) {
|
||||
resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":$gameID,"result":"b"}""")).asObject()
|
||||
// Extract results
|
||||
val results = forcedGames.map { game -> game.toString().split("r\":\"")[1][0] }
|
||||
for (j in 0 .. forcedGames.size-1) {
|
||||
resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":${firstGameID + j},"result":"${results[j]}"}""")).asObject()
|
||||
assertTrue(resp.getBoolean("success") == true, "expecting success")
|
||||
}
|
||||
|
||||
logger.info("Results succesfully entered for round $round")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user