Skip to content

Commit

Permalink
Add the bot token to the test env (#1056)
Browse files Browse the repository at this point in the history
* Add the token to the env

* Update python-test.yml

* Update test_lichess.py

* Update test_lichess.py

* Update test_lichess.py

* Update test_lichess.py
  • Loading branch information
AttackingOrDefending authored Dec 16, 2024
1 parent 0399bd8 commit e19f690
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
TEMP
key: ${{ matrix.os }}-engines
- name: Test with pytest
env:
LICHESS_BOT_TEST_TOKEN: ${{secrets.LICHESS_BOT_TEST_TOKEN}}
run: |
pytest --log-cli-level=10
- name: Save engines
Expand Down
38 changes: 17 additions & 21 deletions test_bot/test_lichess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

def test_lichess() -> None:
"""Test the lichess communication."""
token = os.getenv("LICHESS_BOT_TEST_TOKEN")
if token is None:
token = os.environ.get("LICHESS_BOT_TEST_TOKEN")
if not token:
pytest.skip("Lichess-bot test token must be set.")
li = lichess.Lichess(token, "https://lichess.org/", "0.0.0", logging.DEBUG, 3)
assert len(li.get_online_bots()) > 20
Expand All @@ -28,22 +28,18 @@ def test_lichess() -> None:
'url': 'https://lichess.org/@/BadSunfish', 'username': 'BadSunfish'}
assert li.get_ongoing_games() == []
assert li.is_online("NNWithSF") is False
assert li.get_public_data("lichapibot") == {'blocking': False,
'count': {'ai': 1, 'all': 15774, 'bookmark': 0, 'draw': 3009, 'drawH': 3009,
'import': 0, 'loss': 6423, 'lossH': 6423,
'me': 0, 'playing': 0, 'rated': 15121, 'win': 6342, 'winH': 6341},
'createdAt': 1524037267522, 'followable': True, 'following': False,
'id': 'lichapibot',
'perfs': {'blitz': {'games': 2430, 'prog': 3, 'prov': True, 'rating': 2388,
'rd': 142},
'bullet': {'games': 7293, 'prog': 9, 'prov': True, 'rating': 2298,
'rd': 133},
'classical': {'games': 0, 'prog': 0, 'prov': True, 'rating': 1500,
'rd': 500},
'correspondence': {'games': 0, 'prog': 0, 'prov': True,
'rating': 1500, 'rd': 500},
'rapid': {'games': 993, 'prog': -80, 'prov': True, 'rating': 2363,
'rd': 149}},
'playTime': {'total': 4111502, 'tv': 1582068}, 'profile': {},
'seenAt': 1669272254317, 'title': 'BOT', 'tosViolation': True,
'url': 'https://lichess.org/@/lichapibot', 'username': 'lichapibot'}
public_data = li.get_public_data("lichapibot")
for key in public_data["perfs"]:
public_data["perfs"][key]["rd"] = 0
assert public_data == {'blocking': False, 'count': {'ai': 1, 'all': 15774, 'bookmark': 0, 'draw': 3009, 'drawH': 3009,
'import': 0, 'loss': 6423, 'lossH': 6423,
'me': 0, 'playing': 0, 'rated': 15121, 'win': 6342, 'winH': 6341},
'createdAt': 1524037267522, 'followable': True, 'following': False, 'id': 'lichapibot',
'perfs': {'blitz': {'games': 2430, 'prog': 3, 'prov': True, 'rating': 2388, 'rd': 0},
'bullet': {'games': 7293, 'prog': 9, 'prov': True, 'rating': 2298, 'rd': 0},
'classical': {'games': 0, 'prog': 0, 'prov': True, 'rating': 1500, 'rd': 0},
'correspondence': {'games': 0, 'prog': 0, 'prov': True, 'rating': 1500, 'rd': 0},
'rapid': {'games': 993, 'prog': -80, 'prov': True, 'rating': 2363, 'rd': 0}},
'playTime': {'total': 4111502, 'tv': 1582068}, 'profile': {},
'seenAt': 1669272254317, 'title': 'BOT', 'tosViolation': True,
'url': 'https://lichess.org/@/lichapibot', 'username': 'lichapibot'}

0 comments on commit e19f690

Please sign in to comment.