-
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
Support for multiple player ratings #486
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b41aa2c
Get rid of BasePlayer class
39e7a70
Remove Player class mocking in tests
357bd28
Improve game stats coverage
68bb5fa
Use a dict-like object for player ratings
558a3bb
Add asynctest to dependencies
d84b57d
Replace CoroMock with asynctest's CoroutineMock
e69d376
Remove BaseGame class
bf307b4
Fix ban test by formatting >100 year bans as 'forever'
67ee48e
Make the DB non-global
d6fcf51
Use asynctest/pytest-asyncio for tests
2f9260c
Add an event loop fast-forwarding decorator
8995320
Fix some sleep usage in tests
73befb7
A bit more test coverage
0330d0b
Remove no longer needed loop fixture
371a2db
Update game docstring
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
from aiomysql.sa import create_engine | ||
|
||
engine = None | ||
|
||
class FAFDatabase: | ||
def __init__(self, loop): | ||
self._loop = loop | ||
self.engine = None | ||
|
||
def set_engine(engine_): | ||
""" | ||
Set the globally used engine to the given argument | ||
""" | ||
global engine | ||
engine = engine_ | ||
async def connect(self, host='localhost', port=3306, user='root', | ||
password='', db='faf_test', minsize=1, maxsize=1, | ||
echo=True): | ||
if self.engine is not None: | ||
raise ValueError("DB is already connected!") | ||
self.engine = await create_engine( | ||
host=host, | ||
port=port, | ||
user=user, | ||
password=password, | ||
db=db, | ||
autocommit=True, | ||
loop=self._loop, | ||
minsize=minsize, | ||
maxsize=maxsize, | ||
echo=echo | ||
) | ||
|
||
async def close(self): | ||
if self.engine is None: | ||
return | ||
|
||
async def connect_engine( | ||
loop, host='localhost', port=3306, user='root', password='', db='faf_test', | ||
minsize=1, maxsize=1, echo=True | ||
): | ||
engine = await create_engine( | ||
host=host, | ||
port=port, | ||
user=user, | ||
password=password, | ||
db=db, | ||
autocommit=True, | ||
loop=loop, | ||
minsize=minsize, | ||
maxsize=maxsize, | ||
echo=echo | ||
) | ||
|
||
set_engine(engine) | ||
return engine | ||
self.engine.close() | ||
await self.engine.wait_closed() | ||
self.engine = None |
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
Oops, something went wrong.
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.
For now this makes sense, but it won't anymore once you finish multiple rating support :P
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.
You want something else than an enum? Is it supposed to be populated from the db?