Skip to content

Commit

Permalink
Merge branch 'main' into prepare-python-3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Segelzwerg authored Oct 25, 2022
2 parents bf2097a + 56714c3 commit 482d1c9
Show file tree
Hide file tree
Showing 25 changed files with 147 additions and 39 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ exclude =
build
dist
venv
ignore = D200, D204, D205, D400, D401
max-line-length = 100
max-complexity = 10
111 changes: 80 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ passlib = { version = "^1.7", extras = ["bcrypt"] }
splunk-sdk = "^1.7"

[tool.poetry.dev-dependencies]
pytest = "^7.1"
pytest-cov = "^3.0"
pytest = "^7.2"
pytest-cov = "^4.0"
pytest-asyncio = "^0.20"
flake8 = "^5.0"
pylint = "^2.15"
flake8-docstrings = "^1.6.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
5 changes: 5 additions & 0 deletions tests/whist_server/services/test_room_db_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def test_not_existing(self):
with self.assertRaisesRegex(RoomNotFoundError, error_msg):
self.service.get(game_id)

def test_get_invalid_room_id(self):
room_id = '1'
error_msg = f'Room with id "{room_id}" not found.'
with self.assertRaisesRegex(RoomNotFoundError, error_msg):
self.service.get(room_id)
def test_get_by_name(self):
game_id = self.service.add(self.room)
self.room.id = ObjectId(game_id)
Expand Down
1 change: 1 addition & 0 deletions whist_server/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Web API package"""
1 change: 1 addition & 0 deletions whist_server/api/oauth2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Authentication API"""
1 change: 1 addition & 0 deletions whist_server/api/ranking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""User ranking related API"""
1 change: 1 addition & 0 deletions whist_server/api/room/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Room related API"""
2 changes: 0 additions & 2 deletions whist_server/api/room/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def ready_player(room_id: str, user: Player = Security(get_current_user),
:return: dictionary containing the status of whether the action was successful.
Raises 403 exception if the user has not be joined yet.
"""

room = room_service.get(room_id)

try:
Expand All @@ -116,7 +115,6 @@ def unready_player(room_id: str, user: Player = Security(get_current_user),
Raises 404 exception if room_id is not found
Raises 400 exception if player is not ready
"""

room = room_service.get(room_id)

try:
Expand Down
1 change: 0 additions & 1 deletion whist_server/api/room/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def all_rooms(room_service=Depends(RoomDatabaseService),
@router.get('/info/{room_id}', response_model=RoomInfo)
def room_info(room_id: str, room_service=Depends(RoomDatabaseService)) -> RoomInfo:
"""
:param room_id:
:param room_service: Dependency injection of the room service
:return:
Expand Down
1 change: 1 addition & 0 deletions whist_server/api/user/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""User related API"""
2 changes: 2 additions & 0 deletions whist_server/database/id_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PyObjectId(ObjectId):

@classmethod
def __get_validators__(cls):
"""Returns the class' validators."""
yield cls.validate

@classmethod
Expand All @@ -24,4 +25,5 @@ def validate(cls, value):

@classmethod
def __modify_schema__(cls, field_schema):
"""Changes the type to a string."""
field_schema.update(type='string')
5 changes: 5 additions & 0 deletions whist_server/database/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def validate_password_sso(cls, values):
return values

def __init__(self, rating=INITIAL_RATING, **data: Any):
"""
Constructor.
:param rating: The start value of the player's rating.
:param data: dict with 'games' key for amount of games already played
"""
super().__init__(rating=rating, **data)

def verify_password(self, password) -> bool:
Expand Down
1 change: 1 addition & 0 deletions whist_server/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Services for API calls"""
1 change: 1 addition & 0 deletions whist_server/services/channel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ChannelService:
_channels: dict[str, SideChannel] = None

def __new__(cls):
"""Creates a new instance of this service singleton."""
if cls._instance is None:
cls._instance = super(ChannelService, cls).__new__(cls)
cls._channels = {}
Expand Down
Loading

0 comments on commit 482d1c9

Please sign in to comment.