Add test for Swiss pairings

This commit is contained in:
Quentin Rendu
2023-06-25 16:18:00 +02:00
parent 38774a78d1
commit db4eaa851e
3 changed files with 60 additions and 16 deletions

View File

@@ -7,12 +7,12 @@ import org.junit.jupiter.api.MethodOrderer.MethodName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestMethodOrder
import java.io.*
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail
@TestMethodOrder(MethodName::class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BasicTests: TestBase() {
@@ -38,6 +38,27 @@ class BasicTests: TestBase() {
)
)
val aSimpleSwissTournament = Json.Object(
"type" to "INDIVIDUAL",
"name" to "Simple Swiss",
"shortName" to "simple-swiss",
"startDate" to "2023-05-10",
"endDate" to "2023-05-12",
"country" to "FR",
"location" to "Grenoble",
"online" to false,
"timeSystem" to Json.Object(
"type" to "FISCHER",
"mainTime" to 1800,
"increment" to 15
),
"rounds" to 4,
"pairing" to Json.Object(
"type" to "SWISS",
"method" to "SPLIT_AND_SLIP"
)
)
val aTeamTournament = Json.Object(
"type" to "TEAM2",
"name" to "Mon Tournoi par équipes",
@@ -184,4 +205,20 @@ class BasicTests: TestBase() {
// TODO check pairing
// val expected = """"["id":1,"w":5,"b":6,"h":3,"r":"?"]"""
}
@Test
fun `008 simple swiss tournament`() {
var resp = TestAPI.post("/api/tour", aSimpleSwissTournament).asObject()
assertTrue(resp.getBoolean("success") == true, "expecting success")
aTournamentID = resp.getInt("id")
resp = TestAPI.post("/api/tour/$aTeamTournamentID/part", aPlayer).asObject()
assertTrue(resp.getBoolean("success") == true, "expecting success")
val inputStream: InputStream = getTestFile("aSimpleSwiss/PlayersList.json").inputStream()
val inputString = inputStream.bufferedReader().use { it.readText() }
println(inputString)
}
}