Fix tests, move weights.txt out of src

This commit is contained in:
Claude Brisson
2023-12-26 13:09:15 +01:00
parent 2629ea9b9d
commit 14a88c1c26
8 changed files with 65 additions and 66 deletions

View File

@@ -21,20 +21,20 @@ class TeamTest {
resp = TestAPI.post("/api/tour/$aTeamTournamentID/part", anotherPlayer).asObject()
assertTrue(resp.getBoolean("success") == true, "expecting success")
val anotherTeamPlayerID = resp.getInt("id") ?: fail("id cannot be null")
var arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asArray()
var arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asObject().getArray("pairables")
assertEquals("[]", arr.toString(), "expecting an empty array")
resp = TestAPI.post("/api/tour/$aTeamTournamentID/team", Json.parse("""{ "name":"The Buffallos", "players":[$aTeamPlayerID, $anotherTeamPlayerID] }""")?.asObject() ?: fail("no null allowed here")).asObject()
assertTrue(resp.getBoolean("success") == true, "expecting success")
val aTeamID = resp.getInt("id") ?: error("no null allowed here")
resp = TestAPI.get("/api/tour/$aTeamTournamentID/team/$aTeamID").asObject()
assertEquals("""{"id":$aTeamID,"name":"The Buffallos","players":[$aTeamPlayerID,$anotherTeamPlayerID]}""", resp.toString(), "expecting team description")
arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asArray()
arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asObject().getArray("pairables")
assertEquals("[$aTeamID]", arr.toString(), "expecting a singleton array")
// nothing stops us in reusing players in different teams, at least for now...
resp = TestAPI.post("/api/tour/$aTeamTournamentID/team", Json.parse("""{ "name":"The Billies", "players":[$aTeamPlayerID, $anotherTeamPlayerID] }""")?.asObject() ?: fail("no null here")).asObject()
assertTrue(resp.getBoolean("success") == true, "expecting success")
val anotherTeamID = resp.getInt("id") ?: fail("no null here")
arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asArray()
arr = TestAPI.get("/api/tour/$aTeamTournamentID/pair/1").asObject().getArray("pairables")
assertEquals("[$aTeamID,$anotherTeamID]", arr.toString(), "expecting two pairables")
arr = TestAPI.post("/api/tour/$aTeamTournamentID/pair/1", Json.parse("""["all"]""")).asArray()
assertTrue(resp.getBoolean("success") == true, "expecting success")