-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from wednesday-solutions/feat/code_refactor
Feat/code refactor according to sonar standards
- Loading branch information
Showing
18 changed files
with
166 additions
and
97 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from __future__ import annotations | ||
|
||
from .redis_config import get_redis_pool | ||
|
||
|
||
__all__ = [ | ||
"engine", | ||
"get_redis_pool", | ||
] |
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,14 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
import asyncio | ||
import random | ||
|
||
from app.exceptions import ExternalServiceException | ||
|
||
|
||
async def external_service_call(): | ||
# Simulate network delay | ||
delay = random.uniform(0.1, 1.0) # Random delay between 0.1 to 1.0 seconds | ||
delay = random.uniform(0.1, 1.0) # Random delay between 0.1 to 1.0 seconds #NOSONAR | ||
await asyncio.sleep(delay) | ||
|
||
# Simulate occasional failures | ||
if random.random() < 0.2: # 20% chance of failure | ||
raise Exception("External service failed") | ||
if random.random() < 0.2: # 20% chance of failure #NOSONAR | ||
raise ExternalServiceException("External Service Failed") | ||
|
||
return "Success from external service" |
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,24 @@ | ||
class ExternalServiceException(Exception): | ||
pass | ||
|
||
|
||
class NoUserFoundException(Exception): | ||
pass | ||
class EmailAlreadyExistException(Exception): | ||
pass | ||
|
||
class MobileAlreadyExistException(Exception): | ||
pass | ||
|
||
class InvalidCredentialsException(Exception): | ||
pass | ||
|
||
class CentryTestException(Exception): | ||
pass | ||
|
||
class DatabaseConnectionException(Exception): | ||
pass | ||
|
||
|
||
class RedisUrlNotFoundException(Exception): | ||
pass |
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
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.
effef37
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.
Coverage Report