Skip to content

Commit

Permalink
move test expected df to snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
guidopetri committed Sep 1, 2024
1 parent 0e31973 commit 98cd597
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 56 deletions.
4 changes: 4 additions & 0 deletions tests/vendors/__snapshots__/test_lichess.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# serializer version: 1
# name: test_lichess_api_json_single_day
'{"id":{"0":"q7ZvsdUF"},"rated":{"0":true},"variant":{"0":"standard"},"speed":{"0":"blitz"},"perf":{"0":"blitz"},"createdAt":{"0":1514505150384},"lastMoveAt":{"0":1514505592843},"status":{"0":"draw"},"moves":{"0":"d4 d5 c4 c6 Nc3 e6"},"players_white_user_name":{"0":"Lance5500"},"players_white_user_title":{"0":"LM"},"players_white_user_patron":{"0":true},"players_white_user_id":{"0":"lance5500"},"players_white_rating":{"0":2389},"players_white_ratingDiff":{"0":4},"players_black_user_name":{"0":"TryingHard87"},"players_black_user_id":{"0":"tryinghard87"},"players_black_rating":{"0":2498},"players_black_ratingDiff":{"0":-4},"opening_eco":{"0":"D31"},"opening_name":{"0":"Semi-Slav Defense: Marshall Gambit"},"opening_ply":{"0":7},"clock_initial":{"0":300},"clock_increment":{"0":3},"clock_totalTime":{"0":420}}'
# ---
58 changes: 2 additions & 56 deletions tests/vendors/test_lichess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from datetime import datetime

import freezegun
import pandas as pd
import pytest
from lichess.format import JSON, PYCHESS
from vendors.lichess import fetch_lichess_api_json, fetch_lichess_api_pgn
Expand Down Expand Up @@ -71,7 +70,7 @@ def mock_parse_headers(mocker):
)


def test_lichess_api_json_single_day(mocker, mock_lichess_api_json):
def test_lichess_api_json_single_day(mocker, mock_lichess_api_json, snapshot):
player = 'thibault'
perf_type = 'bullet'
since = datetime(2024, 4, 28)
Expand All @@ -97,60 +96,7 @@ def test_lichess_api_json_single_day(mocker, mock_lichess_api_json):
format=JSON,
)

expected = pd.DataFrame([['q7ZvsdUF',
True,
'standard',
'blitz',
'blitz',
1514505150384,
1514505592843,
'draw',
'd4 d5 c4 c6 Nc3 e6',
'Lance5500',
'LM',
True,
'lance5500',
2389,
4,
'TryingHard87',
'tryinghard87',
2498,
-4,
'D31',
'Semi-Slav Defense: Marshall Gambit',
7,
300,
3,
420,
]],
columns=['id',
'rated',
'variant',
'speed',
'perf',
'createdAt',
'lastMoveAt',
'status',
'moves',
'players_white_user_name',
'players_white_user_title',
'players_white_user_patron',
'players_white_user_id',
'players_white_rating',
'players_white_ratingDiff',
'players_black_user_name',
'players_black_user_id',
'players_black_rating',
'players_black_ratingDiff',
'opening_eco',
'opening_name',
'opening_ply',
'clock_initial',
'clock_increment',
'clock_totalTime',
]
)
pd.testing.assert_frame_equal(df, expected)
assert df.to_json() == snapshot


@freezegun.freeze_time('2024-04-30 00:00:00')
Expand Down

0 comments on commit 98cd597

Please sign in to comment.