Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkflame72 committed Oct 5, 2020
1 parent deb6f1e commit af10218
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def tests(session: Session) -> None:
"pytest-cov",
"pytest-mock",
"pytest-asyncio",
"cryptography",
)
session.run("pytest", *args)

Expand Down
47 changes: 40 additions & 7 deletions tests/test_mcsrvstats.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
"""Main tests."""

import asyncio
import socket
from collections import namedtuple

import aiohttp
import pytest

from mcsrvstats import __version__, Client
from tests.aiohttp import http_redirect, CaseControlledTestServer
from tests.certificate import ssl_certificate, TemporaryCertificate
from tests.aiohttp import CaseControlledTestServer, http_redirect
from tests.certificate import ssl_certificate, TemporaryCertificate # noqa: F401

TIMEOUT = 1

Expand All @@ -20,7 +17,7 @@ def test_version() -> None:


@pytest.mark.asyncio
async def test_hiveMCAchievements(http_redirect):
async def test_hiveMCAchievements(http_redirect): # noqa: F401
async with CaseControlledTestServer() as server:
http_redirect.add_server("api.hivemc.com", 80, server.port)
client = Client(session=http_redirect.session)
Expand All @@ -31,7 +28,43 @@ async def test_hiveMCAchievements(http_redirect):

server.send_response(
request,
text='{"username":"Lord_Ewout","rankName":"Regular Hive Member","legacyRank":null,"modernRank":{"enum":"EMERALD","human":"Emerald Premium","index":30},"tokens":6390538,"credits":0,"medals":4282,"crates":0,"UUID":"a12d8264f19746e6878a0ab9ac8617ac","status":{"description":"Currently hibernating in","game":"the Land of Nods!"},"cached":1601853120,"firstLogin":1372006132,"lastLogin":1595021951,"lastLogout":1595021964,"achievements":{"THESWARM":{"progress":1,"unlockedAt":1422286300,"from":"079a7d06aa054ab2be047ce818427556","game":"HideAndSeek"},"SPREDDIT":{"progress":25,"unlockedAt":1424440011},"FRIENDJOINFRIEND":{"progress":1,"unlockedAt":1422199571},"HUB":{"progress":1,"unlockedAt":1422192681},"DENIED":{"progress":1,"unlockedAt":1422193105},"FRIENDACCEPTINVITE":{"progress":1,"unlockedAt":1422193671},"FRIEND10":{"progress":1,"unlockedAt":1422192567},"FRIENDMSG":{"progress":1,"unlockedAt":1422192697},"FRIENDDENY":{"progress":1,"unlockedAt":1422193650},"FRIEND1":{"progress":1,"unlockedAt":1422192567},"FRIENDREMOVE":{"progress":1,"unlockedAt":1422211225},"PLAY1":{"progress":1,"unlockedAt":1422207989},"SESSION3":{"progress":1,"unlockedAt":1422224679},"PLAY24":{"progress":1,"unlockedAt":1422544015},"PLAY168":{"progress":1,"unlockedAt":1424275234},"FRIENDINVITE":{"progress":1,"unlockedAt":1427914832},"PARTYDISBAND":{"progress":1,"unlockedAt":1468502987},"PARTYOWNER":{"progress":1,"unlockedAt":1468501324},"PARTYTELEPORT":{"progress":1,"unlockedAt":1468501060},"PARTYACCEPT":{"progress":1,"unlockedAt":1468500450},"PARTYINVITE":{"progress":1,"unlockedAt":1468501621},"PARTYLEAVE":{"progress":1,"unlockedAt":1468704418},"PARTYKICK":{"progress":1,"unlockedAt":1469725361},"PARTYMAX":{"progress":1,"unlockedAt":1474731094},"JOIN3":{"progress":1,"unlockedAt":1485389316},"JOIN1":{"progress":1,"unlockedAt":1485389316},"JOIN2":{"progress":1,"unlockedAt":1485389316},"JOIN4":{"progress":1,"unlockedAt":1516649753},"FRIENDFAVORITE":{"progress":1,"unlockedAt":1529523010},"JOIN5":{"progress":1,"unlockedAt":1529792911},"JOIN6":{"progress":1,"unlockedAt":1567552622}},"trophies":[{"game":"Global","achievement":"JOIN3"},{"game":"Global","achievement":"JOIN2"},{"game":"Global","achievement":"JOIN5"},{"game":"Global","achievement":"JOIN6"},{"game":"BP","achievement":"MASTER"},{"game":"Global","achievement":"JOIN1"},{"game":"Global","achievement":"JOIN4"}]}',
text='{"username":"Lord_Ewout","rankName":"Regular Hive Member","l'
+ 'egacyRank":null,"modernRank":{"enum":"EMERALD","human":"Emerald P'
+ 'remium","index":30},"tokens":6390538,"credits":0,"medals":4282,"c'
+ 'rates":0,"UUID":"a12d8264f19746e6878a0ab9ac8617ac","status":{"des'
+ 'cription":"Currently hibernating in","game":"the Land of Nods!"},'
+ '"cached":1601853120,"firstLogin":1372006132,"lastLogin":159502195'
+ '1,"lastLogout":1595021964,"achievements":{"THESWARM":{"progress":'
+ '1,"unlockedAt":1422286300,"from":"079a7d06aa054ab2be047ce81842755'
+ '6","game":"HideAndSeek"},"SPREDDIT":{"progress":25,"unlockedAt":1'
+ '424440011},"FRIENDJOINFRIEND":{"progress":1,"unlockedAt":14221995'
+ '71},"HUB":{"progress":1,"unlockedAt":1422192681},"DENIED":{"progr'
+ 'ess":1,"unlockedAt":1422193105},"FRIENDACCEPTINVITE":{"progress":'
+ '1,"unlockedAt":1422193671},"FRIEND10":{"progress":1,"unlockedAt":'
+ '1422192567},"FRIENDMSG":{"progress":1,"unlockedAt":1422192697},"F'
+ 'RIENDDENY":{"progress":1,"unlockedAt":1422193650},"FRIEND1":{"pro'
+ 'gress":1,"unlockedAt":1422192567},"FRIENDREMOVE":{"progress":1,"u'
+ 'nlockedAt":1422211225},"PLAY1":{"progress":1,"unlockedAt":1422207'
+ '989},"SESSION3":{"progress":1,"unlockedAt":1422224679},"PLAY24":{'
+ '"progress":1,"unlockedAt":1422544015},"PLAY168":{"progress":1,"un'
+ 'lockedAt":1424275234},"FRIENDINVITE":{"progress":1,"unlockedAt":1'
+ '427914832},"PARTYDISBAND":{"progress":1,"unlockedAt":1468502987},'
+ '"PARTYOWNER":{"progress":1,"unlockedAt":1468501324},"PARTYTELEPOR'
+ 'T":{"progress":1,"unlockedAt":1468501060},"PARTYACCEPT":{"progres'
+ 's":1,"unlockedAt":1468500450},"PARTYINVITE":{"progress":1,"unlock'
+ 'edAt":1468501621},"PARTYLEAVE":{"progress":1,"unlockedAt":1468704'
+ '418},"PARTYKICK":{"progress":1,"unlockedAt":1469725361},"PARTYMAX'
+ '":{"progress":1,"unlockedAt":1474731094},"JOIN3":{"progress":1,"u'
+ 'nlockedAt":1485389316},"JOIN1":{"progress":1,"unlockedAt":1485389'
+ '316},"JOIN2":{"progress":1,"unlockedAt":1485389316},"JOIN4":{"pro'
+ 'gress":1,"unlockedAt":1516649753},"FRIENDFAVORITE":{"progress":1,'
+ '"unlockedAt":1529523010},"JOIN5":{"progress":1,"unlockedAt":15297'
+ '92911},"JOIN6":{"progress":1,"unlockedAt":1567552622}},"trophies"'
+ ':[{"game":"Global","achievement":"JOIN3"},{"game":"Global","achie'
+ 'vement":"JOIN2"},{"game":"Global","achievement":"JOIN5"},{"game":'
+ '"Global","achievement":"JOIN6"},{"game":"BP","achievement":"MASTE'
+ 'R"},{"game":"Global","achievement":"JOIN1"},{"game":"Global","ach'
+ 'ievement":"JOIN4"}]}',
content_type="application/json",
)
result = await asyncio.wait_for(task, TIMEOUT)
Expand Down

0 comments on commit af10218

Please sign in to comment.