mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-07-01 20:26:27 +00:00
Compare commits
12 Commits
14f4cef426
...
master
Author | SHA1 | Date | |
---|---|---|---|
908613306f
|
|||
38e0d7f8d1
|
|||
937bbe2eee
|
|||
e7398be07e
|
|||
64285c350c
|
|||
62c3431cff
|
|||
280543660a
|
|||
8dc433b12a
|
|||
2bd64bbd5e
|
|||
54749c8df2
|
|||
36364d6e3d
|
|||
b14c3e82b4
|
48
.github/workflows/build-and-draft-release.yml
vendored
Normal file
48
.github/workflows/build-and-draft-release.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: "Build and draft a release"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
discussions: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-draft-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Python environment
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.x"
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
run: |
|
||||||
|
pip install build
|
||||||
|
python -m build
|
||||||
|
|
||||||
|
- name: Remove `v` in tag name
|
||||||
|
uses: mad9000/actions-find-and-replace-string@5
|
||||||
|
id: tagNameReplaced
|
||||||
|
with:
|
||||||
|
source: ${{ github.ref_name }}
|
||||||
|
find: "v"
|
||||||
|
replace: ""
|
||||||
|
|
||||||
|
- name: Draft a release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
discussion_category_name: New releases
|
||||||
|
draft: true
|
||||||
|
generate_release_notes: true
|
||||||
|
files: |
|
||||||
|
dist/arcaea_offline-${{ steps.tagNameReplaced.outputs.value }}*.whl
|
||||||
|
dist/arcaea-offline-${{ steps.tagNameReplaced.outputs.value }}.tar.gz
|
40
.github/workflows/main.yml
vendored
Normal file
40
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: test & lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pytest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dev dependencies
|
||||||
|
run: 'pip install .[dev]'
|
||||||
|
- name: Run tests
|
||||||
|
run: 'pytest -v'
|
||||||
|
|
||||||
|
ruff:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: Install dev dependencies
|
||||||
|
run: 'pip install .[dev]'
|
||||||
|
- name: Run linter
|
||||||
|
run: 'ruff check'
|
@ -4,11 +4,10 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/psf/black
|
|
||||||
rev: 23.1.0
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.4.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
- repo: https://github.com/PyCQA/isort
|
args: ["--fix"]
|
||||||
rev: 5.12.0
|
- id: ruff-format
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
|
2
.sourcery.yaml
Normal file
2
.sourcery.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rule_settings:
|
||||||
|
python_version: '3.8'
|
@ -10,9 +10,14 @@ English | [简体中文](./README.zh_Hans.md)
|
|||||||
|
|
||||||
## WIP
|
## WIP
|
||||||
|
|
||||||
> **Warning**
|
> [!CAUTION]
|
||||||
> This project is under active development, thus it is unstable and API may change frequently.
|
> This project is under active development, thus it is unstable and API may change frequently.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> v0.3.0 is under development, check out [this branch](https://github.com/283375/arcaea-offline/tree/0.3.0-refactor)!
|
||||||
|
>
|
||||||
|
> Once v0.3.0 is ready for release, this repository will be transferred to *[ArcaeaOffline](https://github.com/ArcaeaOffline)/core-python*
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|
||||||
This is the core library of `Arcaea Offline`, designed to manage player scores, calculate their potential, and provide various useful tools.
|
This is the core library of `Arcaea Offline`, designed to manage player scores, calculate their potential, and provide various useful tools.
|
||||||
|
@ -8,9 +8,14 @@
|
|||||||
|
|
||||||
## WIP
|
## WIP
|
||||||
|
|
||||||
> **Warning**
|
> [!CAUTION]
|
||||||
> 该项目正处于早期开发阶段,不能保证稳定性,且 API 可能随时变动。
|
> 该项目正处于早期开发阶段,不能保证稳定性,且 API 可能随时变动。
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> v0.3.0 正在[此分支](https://github.com/283375/arcaea-offline/tree/0.3.0-refactor)下开发!
|
||||||
|
>
|
||||||
|
> 在 v0.3.0 准备好发布后,此存储库将被迁移至 *[ArcaeaOffline](https://github.com/ArcaeaOffline)/core-python*。
|
||||||
|
|
||||||
## 这是什么?
|
## 这是什么?
|
||||||
|
|
||||||
这是 `Arcaea Offline` 的核心依赖库,用于维护分数数据库、计算潜力值,并提供一些实用工具。
|
这是 `Arcaea Offline` 的核心依赖库,用于维护分数数据库、计算潜力值,并提供一些实用工具。
|
||||||
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "arcaea-offline"
|
name = "arcaea-offline"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
authors = [{ name = "283375", email = "log_283375@163.com" }]
|
authors = [{ name = "283375", email = "log_283375@163.com" }]
|
||||||
description = "Manage your local Arcaea score database."
|
description = "Manage your local Arcaea score database."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -20,24 +20,34 @@ classifiers = [
|
|||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = ["ruff~=0.4", "pre-commit~=3.3", "pytest~=7.4", "tox~=4.11"]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
"Homepage" = "https://github.com/283375/arcaea-offline"
|
"Homepage" = "https://github.com/283375/arcaea-offline"
|
||||||
"Bug Tracker" = "https://github.com/283375/arcaea-offline/issues"
|
"Bug Tracker" = "https://github.com/283375/arcaea-offline/issues"
|
||||||
|
|
||||||
[tool.isort]
|
|
||||||
profile = "black"
|
|
||||||
src_paths = ["src/arcaea_offline"]
|
|
||||||
|
|
||||||
[tool.pyright]
|
[tool.pyright]
|
||||||
ignore = ["build/"]
|
ignore = ["build/"]
|
||||||
|
|
||||||
[tool.pylint.main]
|
[tool.ruff.lint]
|
||||||
jobs = 0
|
# Full list: https://docs.astral.sh/ruff/rules
|
||||||
|
select = [
|
||||||
[tool.pylint.logging]
|
"E", # pycodestyle (Error)
|
||||||
disable = [
|
"W", # pycodestyle (Warning)
|
||||||
"missing-module-docstring",
|
"F", # pyflakes
|
||||||
"missing-class-docstring",
|
"I", # isort
|
||||||
"missing-function-docstring",
|
"PL", # pylint
|
||||||
"not-callable", # false positive to sqlalchemy `func.*`, remove this when pylint-dev/pylint(#8138) closed
|
"N", # pep8-naming
|
||||||
|
"FBT", # flake8-boolean-trap
|
||||||
|
"A", # flake8-builtins
|
||||||
|
"DTZ", # flake8-datetimez
|
||||||
|
"LOG", # flake8-logging
|
||||||
|
"Q", # flake8-quotes
|
||||||
|
"G", # flake8-logging-format
|
||||||
|
"PIE", # flake8-pie
|
||||||
|
"PT", # flake8-pytest-style
|
||||||
|
]
|
||||||
|
ignore = [
|
||||||
|
"E501", # line-too-long
|
||||||
]
|
]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
black==23.3.0
|
ruff~=0.4
|
||||||
isort==5.12.0
|
pre-commit~=3.3
|
||||||
pre-commit==3.3.1
|
pytest~=7.4
|
||||||
pylint==3.0.2
|
tox~=4.11
|
||||||
|
@ -6,7 +6,7 @@ from sqlalchemy import Engine, func, inspect, select
|
|||||||
from sqlalchemy.orm import DeclarativeBase, InstrumentedAttribute, sessionmaker
|
from sqlalchemy.orm import DeclarativeBase, InstrumentedAttribute, sessionmaker
|
||||||
|
|
||||||
from .external.arcsong.arcsong_json import ArcSongJsonBuilder
|
from .external.arcsong.arcsong_json import ArcSongJsonBuilder
|
||||||
from .external.exports import ScoreExport, exporters
|
from .external.exports import ArcaeaOfflineDEFV2_Score, ScoreExport, exporters
|
||||||
from .models.config import ConfigBase, Property
|
from .models.config import ConfigBase, Property
|
||||||
from .models.scores import (
|
from .models.scores import (
|
||||||
CalculatedPotential,
|
CalculatedPotential,
|
||||||
@ -410,6 +410,15 @@ class Database(metaclass=Singleton):
|
|||||||
scores = self.get_scores()
|
scores = self.get_scores()
|
||||||
return [exporters.score(score) for score in scores]
|
return [exporters.score(score) for score in scores]
|
||||||
|
|
||||||
|
def export_scores_def_v2(self) -> ArcaeaOfflineDEFV2_Score:
|
||||||
|
scores = self.get_scores()
|
||||||
|
return {
|
||||||
|
"$schema": "https://arcaeaoffline.sevive.xyz/schemas/def/v2/score.schema.json",
|
||||||
|
"type": "score",
|
||||||
|
"version": 2,
|
||||||
|
"scores": [exporters.score_def_v2(score) for score in scores],
|
||||||
|
}
|
||||||
|
|
||||||
def generate_arcsong(self):
|
def generate_arcsong(self):
|
||||||
with self.sessionmaker() as session:
|
with self.sessionmaker() as session:
|
||||||
arcsong = ArcSongJsonBuilder(session).generate_arcsong_json()
|
arcsong = ArcSongJsonBuilder(session).generate_arcsong_json()
|
||||||
|
1
src/arcaea_offline/external/chart_info_db/__init__.py
vendored
Normal file
1
src/arcaea_offline/external/chart_info_db/__init__.py
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
from .parser import ChartInfoDbParser
|
35
src/arcaea_offline/external/chart_info_db/parser.py
vendored
Normal file
35
src/arcaea_offline/external/chart_info_db/parser.py
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import contextlib
|
||||||
|
import sqlite3
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from ...models.songs import ChartInfo
|
||||||
|
|
||||||
|
|
||||||
|
class ChartInfoDbParser:
|
||||||
|
def __init__(self, filepath):
|
||||||
|
self.filepath = filepath
|
||||||
|
|
||||||
|
def parse(self) -> List[ChartInfo]:
|
||||||
|
results = []
|
||||||
|
with sqlite3.connect(self.filepath) as conn:
|
||||||
|
with contextlib.closing(conn.cursor()) as cursor:
|
||||||
|
db_results = cursor.execute(
|
||||||
|
"SELECT song_id, rating_class, constant, notes FROM charts_info"
|
||||||
|
).fetchall()
|
||||||
|
for result in db_results:
|
||||||
|
chart = ChartInfo(
|
||||||
|
song_id=result[0],
|
||||||
|
rating_class=result[1],
|
||||||
|
constant=result[2],
|
||||||
|
notes=result[3] or None,
|
||||||
|
)
|
||||||
|
results.append(chart)
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
def write_database(self, session: Session):
|
||||||
|
results = self.parse()
|
||||||
|
for result in results:
|
||||||
|
session.merge(result)
|
@ -1,2 +1,2 @@
|
|||||||
from . import exporters
|
from . import exporters
|
||||||
from .types import ScoreExport
|
from .types import ArcaeaOfflineDEFV2_Score, ScoreExport
|
||||||
|
20
src/arcaea_offline/external/exports/exporters.py
vendored
20
src/arcaea_offline/external/exports/exporters.py
vendored
@ -1,5 +1,5 @@
|
|||||||
from ...models import Score
|
from ...models import Score
|
||||||
from .types import ScoreExport
|
from .types import ArcaeaOfflineDEFV2_ScoreItem, ScoreExport
|
||||||
|
|
||||||
|
|
||||||
def score(score: Score) -> ScoreExport:
|
def score(score: Score) -> ScoreExport:
|
||||||
@ -17,3 +17,21 @@ def score(score: Score) -> ScoreExport:
|
|||||||
"clear_type": score.clear_type,
|
"clear_type": score.clear_type,
|
||||||
"comment": score.comment,
|
"comment": score.comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def score_def_v2(score: Score) -> ArcaeaOfflineDEFV2_ScoreItem:
|
||||||
|
return {
|
||||||
|
"id": score.id,
|
||||||
|
"songId": score.song_id,
|
||||||
|
"ratingClass": score.rating_class,
|
||||||
|
"score": score.score,
|
||||||
|
"pure": score.pure,
|
||||||
|
"far": score.far,
|
||||||
|
"lost": score.lost,
|
||||||
|
"date": score.date,
|
||||||
|
"maxRecall": score.max_recall,
|
||||||
|
"modifier": score.modifier,
|
||||||
|
"clearType": score.clear_type,
|
||||||
|
"source": None,
|
||||||
|
"comment": score.comment,
|
||||||
|
}
|
||||||
|
31
src/arcaea_offline/external/exports/types.py
vendored
31
src/arcaea_offline/external/exports/types.py
vendored
@ -1,4 +1,4 @@
|
|||||||
from typing import Optional, TypedDict
|
from typing import List, Literal, Optional, TypedDict
|
||||||
|
|
||||||
|
|
||||||
class ScoreExport(TypedDict):
|
class ScoreExport(TypedDict):
|
||||||
@ -14,3 +14,32 @@ class ScoreExport(TypedDict):
|
|||||||
modifier: Optional[int]
|
modifier: Optional[int]
|
||||||
clear_type: Optional[int]
|
clear_type: Optional[int]
|
||||||
comment: Optional[str]
|
comment: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
|
class ArcaeaOfflineDEFV2_ScoreItem(TypedDict, total=False):
|
||||||
|
id: Optional[int]
|
||||||
|
songId: str
|
||||||
|
ratingClass: int
|
||||||
|
score: int
|
||||||
|
pure: Optional[int]
|
||||||
|
far: Optional[int]
|
||||||
|
lost: Optional[int]
|
||||||
|
date: Optional[int]
|
||||||
|
maxRecall: Optional[int]
|
||||||
|
modifier: Optional[int]
|
||||||
|
clearType: Optional[int]
|
||||||
|
source: Optional[str]
|
||||||
|
comment: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
|
ArcaeaOfflineDEFV2_Score = TypedDict(
|
||||||
|
"ArcaeaOfflineDEFV2_Score",
|
||||||
|
{
|
||||||
|
"$schema": Literal[
|
||||||
|
"https://arcaeaoffline.sevive.xyz/schemas/def/v2/score.schema.json"
|
||||||
|
],
|
||||||
|
"type": Literal["score"],
|
||||||
|
"version": Literal[2],
|
||||||
|
"scores": List[ArcaeaOfflineDEFV2_ScoreItem],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@ -5,6 +5,7 @@ RATING_CLASS_TEXT_MAP = {
|
|||||||
1: "Present",
|
1: "Present",
|
||||||
2: "Future",
|
2: "Future",
|
||||||
3: "Beyond",
|
3: "Beyond",
|
||||||
|
4: "Eternal",
|
||||||
}
|
}
|
||||||
|
|
||||||
RATING_CLASS_SHORT_TEXT_MAP = {
|
RATING_CLASS_SHORT_TEXT_MAP = {
|
||||||
@ -12,6 +13,7 @@ RATING_CLASS_SHORT_TEXT_MAP = {
|
|||||||
1: "PRS",
|
1: "PRS",
|
||||||
2: "FTR",
|
2: "FTR",
|
||||||
3: "BYD",
|
3: "BYD",
|
||||||
|
4: "ETR",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
22
tests/calculate/test_world_step.py
Normal file
22
tests/calculate/test_world_step.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
from arcaea_offline.calculate.world_step import (
|
||||||
|
AwakenedAyuPartnerBonus,
|
||||||
|
LegacyMapStepBooster,
|
||||||
|
PlayResult,
|
||||||
|
calculate_step_original,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_world_step():
|
||||||
|
# the result was copied from https://arcaea.fandom.com/wiki/World_Mode_Mechanics#Calculation
|
||||||
|
# CC BY-SA 3.0
|
||||||
|
|
||||||
|
booster = LegacyMapStepBooster(6, 250)
|
||||||
|
partner_bonus = AwakenedAyuPartnerBonus("+3.6")
|
||||||
|
play_result = PlayResult(play_rating=Decimal("11.299"), partner_step=92)
|
||||||
|
result = calculate_step_original(
|
||||||
|
play_result, partner_bonus=partner_bonus, step_booster=booster
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.quantize(Decimal("0.000")) == Decimal("175.149")
|
0
tests/db/__init__.py
Normal file
0
tests/db/__init__.py
Normal file
5
tests/db/db.py
Normal file
5
tests/db/db.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from sqlalchemy import Engine, create_engine, inspect
|
||||||
|
|
||||||
|
|
||||||
|
def create_engine_in_memory():
|
||||||
|
return create_engine("sqlite:///:memory:")
|
0
tests/db/models/__init__.py
Normal file
0
tests/db/models/__init__.py
Normal file
118
tests/db/models/test_songs.py
Normal file
118
tests/db/models/test_songs.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
from sqlalchemy import Engine
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from arcaea_offline.models.songs import (
|
||||||
|
Chart,
|
||||||
|
ChartInfo,
|
||||||
|
Difficulty,
|
||||||
|
Pack,
|
||||||
|
Song,
|
||||||
|
SongsBase,
|
||||||
|
SongsViewBase,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..db import create_engine_in_memory
|
||||||
|
|
||||||
|
|
||||||
|
def _song(**kw):
|
||||||
|
defaults = {"artist": "test"}
|
||||||
|
defaults.update(kw)
|
||||||
|
return Song(**defaults)
|
||||||
|
|
||||||
|
|
||||||
|
def _difficulty(**kw):
|
||||||
|
defaults = {"rating_plus": False, "audio_override": False, "jacket_override": False}
|
||||||
|
defaults.update(kw)
|
||||||
|
return Difficulty(**defaults)
|
||||||
|
|
||||||
|
|
||||||
|
class Test_Chart:
|
||||||
|
def init_db(self, engine: Engine):
|
||||||
|
SongsBase.metadata.create_all(engine)
|
||||||
|
SongsViewBase.metadata.create_all(engine)
|
||||||
|
|
||||||
|
def db(self):
|
||||||
|
db = create_engine_in_memory()
|
||||||
|
self.init_db(db)
|
||||||
|
return db
|
||||||
|
|
||||||
|
def test_chart_info(self):
|
||||||
|
pre_entites = [
|
||||||
|
Pack(id="test", name="Test Pack"),
|
||||||
|
_song(idx=0, id="song0", set="test", title="Full Chart Info"),
|
||||||
|
_song(idx=1, id="song1", set="test", title="Partial Chart Info"),
|
||||||
|
_song(idx=2, id="song2", set="test", title="No Chart Info"),
|
||||||
|
_difficulty(song_id="song0", rating_class=2, rating=9),
|
||||||
|
_difficulty(song_id="song1", rating_class=2, rating=9),
|
||||||
|
_difficulty(song_id="song2", rating_class=2, rating=9),
|
||||||
|
ChartInfo(song_id="song0", rating_class=2, constant=90, notes=1234),
|
||||||
|
ChartInfo(song_id="song1", rating_class=2, constant=90),
|
||||||
|
]
|
||||||
|
|
||||||
|
db = self.db()
|
||||||
|
with Session(db) as session:
|
||||||
|
session.add_all(pre_entites)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
chart_song0_ratingclass2 = (
|
||||||
|
session.query(Chart)
|
||||||
|
.where((Chart.song_id == "song0") & (Chart.rating_class == 2))
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
|
||||||
|
assert chart_song0_ratingclass2.constant == 90
|
||||||
|
assert chart_song0_ratingclass2.notes == 1234
|
||||||
|
|
||||||
|
chart_song1_ratingclass2 = (
|
||||||
|
session.query(Chart)
|
||||||
|
.where((Chart.song_id == "song1") & (Chart.rating_class == 2))
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
|
||||||
|
assert chart_song1_ratingclass2.constant == 90
|
||||||
|
assert chart_song1_ratingclass2.notes is None
|
||||||
|
|
||||||
|
chart_song2_ratingclass2 = (
|
||||||
|
session.query(Chart)
|
||||||
|
.where((Chart.song_id == "song2") & (Chart.rating_class == 2))
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
|
assert chart_song2_ratingclass2 is None
|
||||||
|
|
||||||
|
def test_difficulty_title_override(self):
|
||||||
|
pre_entites = [
|
||||||
|
Pack(id="test", name="Test Pack"),
|
||||||
|
_song(idx=0, id="test", set="test", title="Test"),
|
||||||
|
_difficulty(song_id="test", rating_class=0, rating=2),
|
||||||
|
_difficulty(song_id="test", rating_class=1, rating=5),
|
||||||
|
_difficulty(song_id="test", rating_class=2, rating=8),
|
||||||
|
_difficulty(
|
||||||
|
song_id="test", rating_class=3, rating=10, title="TEST ~REVIVE~"
|
||||||
|
),
|
||||||
|
ChartInfo(song_id="test", rating_class=0, constant=10),
|
||||||
|
ChartInfo(song_id="test", rating_class=1, constant=10),
|
||||||
|
ChartInfo(song_id="test", rating_class=2, constant=10),
|
||||||
|
ChartInfo(song_id="test", rating_class=3, constant=10),
|
||||||
|
]
|
||||||
|
|
||||||
|
db = self.db()
|
||||||
|
with Session(db) as session:
|
||||||
|
session.add_all(pre_entites)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
charts_original_title = (
|
||||||
|
session.query(Chart)
|
||||||
|
.where((Chart.song_id == "test") & (Chart.rating_class in [0, 1, 2]))
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
|
assert all(chart.title == "Test" for chart in charts_original_title)
|
||||||
|
|
||||||
|
chart_overrided_title = (
|
||||||
|
session.query(Chart)
|
||||||
|
.where((Chart.song_id == "test") & (Chart.rating_class == 3))
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
|
||||||
|
assert chart_overrided_title.title == "TEST ~REVIVE~"
|
Reference in New Issue
Block a user