-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/#687 Fix coop leaderboards again #718
Merged
Askaholic
merged 4 commits into
FAForever:develop
from
Askaholic:issue/#687-coop-leaderboards
Feb 21, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,101 @@ | ||
import datetime | ||
|
||
import pytest | ||
from sqlalchemy import select | ||
|
||
from server.db.models import coop_leaderboard | ||
from tests.utils import fast_forward | ||
|
||
from .conftest import connect_and_sign_in, read_until, read_until_command | ||
from .test_game import host_game, send_player_options | ||
|
||
# All test coroutines will be treated as marked. | ||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
@fast_forward(5) | ||
async def test_host_coop_game(lobby_server): | ||
_, _, proto = await connect_and_sign_in( | ||
("test", "test_password"), | ||
lobby_server | ||
) | ||
|
||
await read_until_command(proto, "game_info") | ||
|
||
await host_game(proto, mod="coop", title="") | ||
|
||
msg = await read_until_command(proto, "game_info") | ||
|
||
assert msg["title"] == "test's game" | ||
assert msg["mapname"] == "scmp_007" | ||
assert msg["map_file_path"] == "maps/scmp_007.zip" | ||
assert msg["featured_mod"] == "coop" | ||
assert msg["game_type"] == "coop" | ||
|
||
|
||
@fast_forward(30) | ||
async def test_single_player_game_recorded(lobby_server, database): | ||
test_id, _, proto = await connect_and_sign_in( | ||
("test", "test_password"), lobby_server | ||
) | ||
await read_until_command(proto, "game_info") | ||
|
||
# Set up the game | ||
game_id = await host_game(proto, mod="coop", mapname="scmp_coop_123.v0002") | ||
# Set player options | ||
await send_player_options( | ||
proto, | ||
[test_id, "Army", 1], | ||
[test_id, "Team", 1], | ||
[test_id, "StartSpot", 1], | ||
[test_id, "Faction", 1], | ||
[test_id, "Color", 1], | ||
) | ||
|
||
# Launch game | ||
await proto.send_message({ | ||
"target": "game", | ||
"command": "GameState", | ||
"args": ["Launching"] | ||
}) | ||
|
||
await read_until( | ||
proto, | ||
lambda cmd: cmd["command"] == "game_info" and cmd["launched_at"] | ||
) | ||
|
||
# End the game | ||
# Single player coop won't report any results | ||
|
||
await proto.send_message({ | ||
"target": "game", | ||
"command": "GameEnded", | ||
"args": [] | ||
}) | ||
|
||
await proto.send_message({ | ||
"target": "game", | ||
"command": "OperationComplete", | ||
"args": [1, 0, "00:11:50"] | ||
}) | ||
|
||
# Now disconnect | ||
await proto.send_message({ | ||
"target": "game", | ||
"command": "GameState", | ||
"args": ["Ended"] | ||
}) | ||
|
||
await read_until_command(proto, "game_info", uid=game_id, state="closed") | ||
|
||
async with database.acquire() as conn: | ||
result = await conn.execute( | ||
select([coop_leaderboard]).where( | ||
coop_leaderboard.c.gameuid == game_id | ||
) | ||
) | ||
row = await result.fetchone() | ||
assert row is not None | ||
assert row.secondary == 0 | ||
assert row.time == datetime.time(0, 11, 50) | ||
assert row.player_count == 1 |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow I didn't realize that there were even more words for true/false used already 😅