From 990efee9003a689205c958bad60152f32e9ef74a Mon Sep 17 00:00:00 2001 From: 283375 Date: Fri, 27 Sep 2024 23:55:41 +0800 Subject: [PATCH] test: use sql script instead of raw database file --- tests/external/importers/arcaea/test_st3.py | 12 +- tests/resources/st3-test.db | Bin 16384 -> 0 bytes tests/resources/st3-test.json | 117 -------------------- tests/resources/st3.sql | 37 +++++++ 4 files changed, 43 insertions(+), 123 deletions(-) delete mode 100644 tests/resources/st3-test.db delete mode 100644 tests/resources/st3-test.json create mode 100644 tests/resources/st3.sql diff --git a/tests/external/importers/arcaea/test_st3.py b/tests/external/importers/arcaea/test_st3.py index 17cdf7a..0db19e8 100644 --- a/tests/external/importers/arcaea/test_st3.py +++ b/tests/external/importers/arcaea/test_st3.py @@ -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 diff --git a/tests/resources/st3-test.db b/tests/resources/st3-test.db deleted file mode 100644 index 89bb53a512d3ffee24a6026ffb9cdc4434d8461c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI&J#W)M7zgk>zqC%2x-q@@lEJ$#0pPytHAhm8-Jts#&#obxmFymC9n=Ch*+ta+6!;U27n+?AW%` z=(NK9q{oxW?n^B>tkHOw1o*Ofv$RpM_?2wBu&zwx7Z&JdcS^xtOYR!C0_{GCw^{pKZl`HauShLHAP`?x7p|7n=LR4;;@;CYJC-{f@?V z9Cv?R__k<-OJ2wAVVtzt{e6`ymw8;1wi5*7;?26;c%Q6tGNQj*!nW6RY)AMbz3hm3 zE8H0gHhMD|TGnW9uCo=wzOc9KfNjfL6bL{70uX=z1Rwwb2tWV=5P$###tU4~b0noH z3Z9<%5eF^8GVA}Y08LC7EEaqBsx;i dJ3}zZ)F@&kk)oba;s)`#fDDbE3?n`O@C)Oc7%>0< diff --git a/tests/resources/st3-test.json b/tests/resources/st3-test.json deleted file mode 100644 index 47826d6..0000000 --- a/tests/resources/st3-test.json +++ /dev/null @@ -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 - } - ] -} diff --git a/tests/resources/st3.sql b/tests/resources/st3.sql new file mode 100644 index 0000000..f546ec2 --- /dev/null +++ b/tests/resources/st3.sql @@ -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');