test: use sql script instead of raw database file

This commit is contained in:
283375 2024-09-27 23:55:41 +08:00
parent 10c869846c
commit 990efee900
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
4 changed files with 43 additions and 123 deletions

View File

@ -2,6 +2,8 @@ import sqlite3
from datetime import datetime
import pytest
import tests.resources
from arcaea_offline.constants.enums.arcaea import (
ArcaeaPlayResultClearType,
ArcaeaPlayResultModifier,
@ -9,16 +11,14 @@ from arcaea_offline.constants.enums.arcaea import (
)
from arcaea_offline.external.importers.arcaea.st3 import ArcaeaSt3Parser
import tests.resources
db = sqlite3.connect(":memory:")
db.executescript(tests.resources.get_resource("st3.sql").read_text(encoding="utf-8"))
class TestSt3Parser:
DB_PATH = tests.resources.get_resource("st3-test.db")
class TestArcaeaSt3Parser:
@property
def play_results(self):
conn = sqlite3.connect(str(self.DB_PATH))
return ArcaeaSt3Parser.parse(conn)
return ArcaeaSt3Parser.parse(db)
def test_basic(self):
play_results = self.play_results

Binary file not shown.

View File

@ -1,117 +0,0 @@
{
"_comment": "A quick preview of the data in st3-test.db",
"scores": [
{
"id": 1,
"version": 1,
"score": 9441167,
"shinyPerfectCount": 753,
"perfectCount": 895,
"nearCount": 32,
"missCount": 22,
"date": 1722100000,
"songId": "test1",
"songDifficulty": 2,
"modifier": 2,
"health": 0,
"ct": 0
},
{
"id": 2,
"version": 1,
"score": 9752087,
"shinyPerfectCount": 914,
"perfectCount": 1024,
"nearCount": 29,
"missCount": 12,
"date": 1722200000,
"songId": "test2",
"songDifficulty": 2,
"modifier": 0,
"health": 100,
"ct": 0
},
{
"id": 3,
"version": 1,
"score": 9750000,
"shinyPerfectCount": 900,
"perfectCount": 1000,
"nearCount": 20,
"missCount": 10,
"date": 1722200000,
"songId": "corrupt1",
"songDifficulty": 5,
"modifier": 0,
"health": 0,
"ct": 0
},
{
"id": 4,
"version": 1,
"score": 9750000,
"shinyPerfectCount": 900,
"perfectCount": 1000,
"nearCount": 20,
"missCount": 10,
"date": 1722200000,
"songId": "corrupt2",
"songDifficulty": 2,
"modifier": 9,
"health": 0,
"ct": 0
},
{
"id": 5,
"version": 1,
"score": 9750000,
"shinyPerfectCount": 900,
"perfectCount": 1000,
"nearCount": 20,
"missCount": 10,
"date": 1,
"songId": "date1",
"songDifficulty": 2,
"modifier": 0,
"health": 0,
"ct": 0
}
],
"cleartypes": [
{
"id": 1,
"songId": "test1",
"songDifficulty": 2,
"clearType": 0,
"ct": 0
},
{
"id": 2,
"songId": "test2",
"songDifficulty": 2,
"clearType": 1,
"ct": 0
},
{
"id": 3,
"songId": "corrupt1",
"songDifficulty": 5,
"clearType": 0,
"ct": 0
},
{
"id": 4,
"songId": "corrupt2",
"songDifficulty": 2,
"clearType": 7,
"ct": 0
},
{
"id": 5,
"songId": "date1",
"songDifficulty": 2,
"clearType": 1,
"ct": 0
}
]
}

37
tests/resources/st3.sql Normal file
View File

@ -0,0 +1,37 @@
CREATE TABLE scores (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
version INTEGER,
score INTEGER,
shinyPerfectCount INTEGER,
perfectCount INTEGER,
nearCount INTEGER,
missCount INTEGER,
date INTEGER,
songId TEXT,
songDifficulty INTEGER,
modifier INTEGER,
health INTEGER,
ct INTEGER DEFAULT 0
);
CREATE TABLE cleartypes (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
songId TEXT,
songDifficulty INTEGER,
clearType INTEGER,
ct INTEGER DEFAULT 0
);
INSERT INTO scores ("id", "version", "score", "shinyPerfectCount", "perfectCount", "nearCount", "missCount", "date", "songId", "songDifficulty", "modifier", "health", "ct") VALUES
('1', '1', '9441167', '753', '895', '32', '22', '1722100000', 'test1', '2', '2', '0', '0'),
('2', '1', '9752087', '914', '1024', '29', '12', '1722200000', 'test2', '2', '0', '100', '0'),
('3', '1', '9750000', '900', '1000', '20', '10', '1722200000', 'corrupt1', '5', '0', '0', '0'),
('4', '1', '9750000', '900', '1000', '20', '10', '1722200000', 'corrupt2', '2', '9', '0', '0'),
('5', '1', '9750000', '900', '1000', '20', '10', '1', 'date1', '2', '0', '0', '0');
INSERT INTO cleartypes ("id", "songId", "songDifficulty", "clearType", "ct") VALUES
('1', 'test1', '2', '0', '0'),
('2', 'test2', '2', '1', '0'),
('3', 'corrupt1', '5', '0', '0'),
('4', 'corrupt2', '2', '7', '0'),
('5', 'date1', '2', '1', '0');