-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unnecessary and poorly coded "point reward for chatting" functionality * Remove unused imports from Bank * Create BankUser protocol with withdraw and deposit methods * Add name method to BankUser protocol * Implement BankUser protocol method name() * Use dependency inversion on Bank's BotUser dependency using the BankUser protocol, decoupling it from BotUser * Make command batch fail on any Exception, not just ValueError * Test banking module * Add get_balance method to BankUser protocol * Use dependency inversion on PointAmount's BotUser dependency * Put test bankuser in a separate module for reuse * Rename exception raised by point converter, validate maximum number of digits and if bank_user is passed for all non-numeric amounts * Test point amount converter * Fix undefined reference on translation module
- Loading branch information
1 parent
f49eb55
commit fa3f2ed
Showing
11 changed files
with
256 additions
and
87 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
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,15 @@ | ||
from typing import Protocol | ||
|
||
|
||
class BankUser(Protocol): | ||
def withdraw(self, amount: int): | ||
... | ||
|
||
def deposit(self, amount: int): | ||
... | ||
|
||
def name(self) -> str: | ||
... | ||
|
||
def get_balance(self) -> int: | ||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from dataclasses import dataclass | ||
|
||
from hashtablebot.bot_exceptions import NotEnoughCoinError | ||
|
||
|
||
@dataclass | ||
class BankUserTest: | ||
""" | ||
Test implementation of BankUser Protocol | ||
""" | ||
|
||
balance: int | ||
|
||
def deposit(self, amount: int): | ||
self.balance += amount | ||
|
||
def withdraw(self, amount: int): | ||
if amount > self.balance: | ||
raise NotEnoughCoinError("Not enough funds") | ||
|
||
self.balance -= amount | ||
|
||
def name(self) -> str: | ||
return "Name" | ||
|
||
def get_balance(self) -> int: | ||
return self.balance |
Oops, something went wrong.