mirror of
https://github.com/rommapp/romm.git
synced 2026-04-18 12:09:38 +00:00
add tests
This commit is contained in:
@@ -7,7 +7,7 @@ cli:
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
ref: v1.7.4
|
||||
ref: v1.7.5
|
||||
uri: https://github.com/trunk-io/plugins
|
||||
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
||||
runtimes:
|
||||
@@ -24,26 +24,26 @@ lint:
|
||||
enabled:
|
||||
- dotenv-linter@4.0.0
|
||||
- hadolint@2.14.0
|
||||
- markdownlint@0.47.0
|
||||
- eslint@9.34.0
|
||||
- actionlint@1.7.10
|
||||
- bandit@1.9.3
|
||||
- black@26.1.0
|
||||
- checkov@3.2.500
|
||||
- markdownlint@0.48.0
|
||||
- eslint@10.0.3
|
||||
- actionlint@1.7.11
|
||||
- bandit@1.9.4
|
||||
- black@26.3.0
|
||||
- checkov@3.2.508
|
||||
- git-diff-check
|
||||
- isort@7.0.0
|
||||
- isort@8.0.1
|
||||
- mypy@1.19.1
|
||||
- osv-scanner@2.3.2
|
||||
- osv-scanner@2.3.3
|
||||
- prettier@3.8.1:
|
||||
packages:
|
||||
- "@trivago/prettier-plugin-sort-imports@6.0.2"
|
||||
- "@vue/compiler-sfc@3.5.27"
|
||||
- ruff@0.15.0
|
||||
- "@vue/compiler-sfc@3.5.29"
|
||||
- ruff@0.15.5
|
||||
- shellcheck@0.11.0
|
||||
- shfmt@3.6.0
|
||||
- taplo@0.10.0
|
||||
- trivy@0.69.1
|
||||
- trufflehog@3.93.1
|
||||
- trivy@0.69.3
|
||||
- trufflehog@3.93.7
|
||||
- yamllint@1.38.0
|
||||
ignore:
|
||||
- linters: [ALL]
|
||||
|
||||
@@ -7,7 +7,7 @@ env =
|
||||
DB_NAME=romm_test
|
||||
DB_USER=romm_test
|
||||
DB_PASSWD=passwd
|
||||
ROMM_DB_DRIVER=mariadb
|
||||
D:ROMM_DB_DRIVER=mariadb
|
||||
IGDB_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
IGDB_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
RETROACHIEVEMENTS_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
@@ -180,6 +180,51 @@ def test_filter_by_search_term_with_multiple_terms(platform: Platform):
|
||||
assert actual_rom_ids_single == expected_rom_ids_single
|
||||
|
||||
|
||||
def test_natural_sort_order(platform: Platform):
|
||||
"""Numbers in names should sort numerically, not lexicographically."""
|
||||
for name in ["Game 10", "Game 2", "Game 1"]:
|
||||
db_rom_handler.add_rom(
|
||||
Rom(
|
||||
platform_id=platform.id,
|
||||
name=name,
|
||||
slug=name.lower().replace(" ", "-"),
|
||||
fs_name=f"{name}.zip",
|
||||
fs_name_no_tags=name,
|
||||
fs_name_no_ext=name,
|
||||
fs_extension="zip",
|
||||
fs_path=f"{platform.slug}/roms",
|
||||
)
|
||||
)
|
||||
|
||||
roms = db_rom_handler.get_roms_scalar(
|
||||
platform_ids=[platform.id], order_by="name", order_dir="asc"
|
||||
)
|
||||
assert [r.name for r in roms] == ["Game 1", "Game 2", "Game 10"]
|
||||
|
||||
|
||||
def test_article_stripping_sort(platform: Platform):
|
||||
"""Leading articles (the, a, an) are stripped when sorting, case-insensitively."""
|
||||
for name in ["Zelda", "The Legend", "A Quest"]:
|
||||
db_rom_handler.add_rom(
|
||||
Rom(
|
||||
platform_id=platform.id,
|
||||
name=name,
|
||||
slug=name.lower().replace(" ", "-"),
|
||||
fs_name=f"{name}.zip",
|
||||
fs_name_no_tags=name,
|
||||
fs_name_no_ext=name,
|
||||
fs_extension="zip",
|
||||
fs_path=f"{platform.slug}/roms",
|
||||
)
|
||||
)
|
||||
|
||||
roms = db_rom_handler.get_roms_scalar(
|
||||
platform_ids=[platform.id], order_by="name", order_dir="asc"
|
||||
)
|
||||
# "The Legend" → sorts as "legend", "A Quest" → "quest", "Zelda" → "zelda"
|
||||
assert [r.name for r in roms] == ["The Legend", "A Quest", "Zelda"]
|
||||
|
||||
|
||||
def test_users(admin_user):
|
||||
db_user_handler.add_user(
|
||||
User(
|
||||
|
||||
Reference in New Issue
Block a user