-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for renamer.new_name_for
- Loading branch information
1 parent
a1e2fef
commit 4216587
Showing
39 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
test: | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
cache: pip | ||
- name: Install shroudstone | ||
run: pip install -e .[test] | ||
- name: Run tests | ||
run: python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pathlib import Path | ||
from typing import NamedTuple | ||
|
||
import pytest | ||
|
||
data_dir = Path(__file__).parent / "replays" | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--update-golden", default=False, action="store_true") | ||
|
||
|
||
class ReplayCase(NamedTuple): | ||
replay_file: Path | ||
summary_file: Path | ||
expected_name_file: Path | ||
|
||
|
||
@pytest.fixture(params=list(data_dir.glob("**/*.SGReplay"))) | ||
def replay_case(request): | ||
path = request.param | ||
yield ReplayCase( | ||
replay_file=path, | ||
summary_file=path.with_suffix(".json"), | ||
expected_name_file=path.with_suffix(".txt"), | ||
) |
Binary file added
BIN
+525 Bytes
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL44821-2024.02.03-18.48.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL44821-2024.02.03-18.48.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-02-03 07.48 L 00m10s Pox IvV PeacefulBot - Boneyard.SGReplay |
Binary file added
BIN
+9.14 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL44821-2024.02.13-22.25.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL44821-2024.02.13-22.25.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-02-13 11.25 L 04m16s Pox IvV PeacefulBot - JaggedMaw.SGReplay |
Binary file added
BIN
+54.8 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.22-16.42.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.22-16.42.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-02-22 05.42 L 10m31s Pox IvV justasloth - BrokenCrown.SGReplay |
Binary file added
BIN
+75.1 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.29-21.25.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.29-21.25.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-02-29 10.25 W 15m04s Pox IvV Frizy - BrokenCrown.SGReplay |
Binary file added
BIN
+9.19 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.29-21.53.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.02.29-21.53.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-02-29 10.53 L 02m13s Pox IvI 你们怎么办,只有天知道 - BrokenCrown.SGReplay |
Binary file added
BIN
+39.6 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.02.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.02.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-06 13.02 W 08m55s Pox IvV itsMerikh - BrokenCrown.SGReplay |
Binary file added
BIN
+64.5 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.12.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.12.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-06 13.12 L 12m29s Pox IvV 물망초 - BrokenCrown.SGReplay |
Binary file added
BIN
+66.9 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.24.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-00.24.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-06 13.24 W 14m49s Pox IvV ελευθερία - BrokenCrown.SGReplay |
Binary file added
BIN
+56.8 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-21.49.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-21.49.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 10.49 L 10m33s Pox IvV TOP - BrokenCrown.SGReplay |
Binary file added
BIN
+95.5 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-21.59.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-21.59.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 10.59 W 17m49s Pox IvV Sturgeon - BrokenCrown.SGReplay |
Binary file added
BIN
+11 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-22.20.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-22.20.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 11.20 W 03m39s Pox IvI thatguy - BrokenCrown.SGReplay |
Binary file added
BIN
+38 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-22.41.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-22.41.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 11.41 W 08m14s Pox IvI indyrem - BrokenCrown.SGReplay |
Binary file added
BIN
+59.9 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.02.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.02.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 12.02 W 12m13s Pox IvI SkWizZ_SSSylas - BrokenCrown.SGReplay |
Binary file added
BIN
+19.7 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.15.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.15.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 12.15 W 04m15s Pox IvI leviotus - BrokenCrown.SGReplay |
Binary file added
BIN
+73.8 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.21.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.21.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 12.21 L 15m13s Pox IvV albino - BrokenCrown.SGReplay |
Binary file added
BIN
+44.4 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.57.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.07-23.57.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-07 12.57 L 10m41s Pox IvV PrimeScout - BrokenCrown.SGReplay |
Binary file added
BIN
+25 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.10-17.05.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.10-17.05.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-10 06.05 W 06m29s Pox IvV Dutchy - BrokenCrown.SGReplay |
Binary file added
BIN
+17.5 KB
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.10-17.12.SGReplay
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/replays/c6b4eb4e-4994-4e96-b098-3e1953a02033/CL45737-2024.03.10-17.12.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-03-10 06.12 W 03m39s Pox IvI Warm Milk - BrokenCrown.SGReplay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from shroudstone.renamer import Replay, new_name_for | ||
from tests.conftest import ReplayCase | ||
|
||
f1v1 = "{time:%Y-%m-%d %H.%M} {result:.1} {duration} {us} {f1:.1}v{f2:.1} {them} - {map_name}.SGReplay" | ||
fgeneric = ( | ||
"{time:%Y-%m-%d %H.%M} {duration} {players_with_factions} - {map_name}.SGReplay" | ||
) | ||
|
||
|
||
def test_replay_renaming(replay_case: ReplayCase, request): | ||
replay = Replay.from_path(replay_case.replay_file) | ||
assert replay is not None | ||
new_name = new_name_for(replay, format_1v1=f1v1, format_generic=fgeneric) | ||
assert isinstance(new_name, str) | ||
if request.config.getoption("--update-golden"): | ||
replay_case.expected_name_file.write_text(new_name) | ||
else: | ||
assert new_name == replay_case.expected_name_file.read_text() |