From 84b3dbe3ce1474a4130ee561ed18bd70519add90 Mon Sep 17 00:00:00 2001 From: 1v Date: Tue, 20 Dec 2022 07:20:49 +0300 Subject: [PATCH] Fix tests --- .../classes/entities/Bet.py | 25 ------------------- .../classes/entities/Strategy.py | 6 ++++- .../entities/strategies/SmartHighOdds.py | 4 +-- TwitchChannelPointsMiner/logger.py | 2 +- 4 files changed, 8 insertions(+), 29 deletions(-) diff --git a/TwitchChannelPointsMiner/classes/entities/Bet.py b/TwitchChannelPointsMiner/classes/entities/Bet.py index 96072c1d..60d4a242 100644 --- a/TwitchChannelPointsMiner/classes/entities/Bet.py +++ b/TwitchChannelPointsMiner/classes/entities/Bet.py @@ -12,17 +12,6 @@ from TwitchChannelPointsMiner.utils import float_round -class Strategy(Enum): - MOST_VOTED = auto() - HIGH_ODDS = auto() - PERCENTAGE = auto() - SMART_MONEY = auto() - SMART = auto() - - def __str__(self): - return self.name - - class Condition(Enum): GT = auto() LT = auto() @@ -33,20 +22,6 @@ def __str__(self): return self.name -class OutcomeKeys(object): - # Real key on Bet dict [''] - PERCENTAGE_USERS = "percentage_users" - ODDS_PERCENTAGE = "odds_percentage" - ODDS = "odds" - TOP_POINTS = "top_points" - # Real key on Bet dict [''] - Sum() - TOTAL_USERS = "total_users" - TOTAL_POINTS = "total_points" - # This key does not exist - DECISION_USERS = "decision_users" - DECISION_POINTS = "decision_points" - - class DelayMode(Enum): FROM_START = auto() FROM_END = auto() diff --git a/TwitchChannelPointsMiner/classes/entities/Strategy.py b/TwitchChannelPointsMiner/classes/entities/Strategy.py index 76fa2228..ed917699 100644 --- a/TwitchChannelPointsMiner/classes/entities/Strategy.py +++ b/TwitchChannelPointsMiner/classes/entities/Strategy.py @@ -2,7 +2,8 @@ from importlib import import_module from random import uniform -from TwitchChannelPointsMiner.utils import char_decision_as_index +def char_decision_as_index(char): + return 0 if char == "A" else 1 class Condition(Enum): @@ -75,9 +76,12 @@ def calculate_after(self, balance: int): >= self.outcomes[index][OutcomeKeys.TOP_POINTS] ): reduce_amount = uniform(1, 5) + # check by + # grep -r --include=*.log "Bet won't be placed as the amount -[0-9] is less than the minimum required 10" . self.decision["amount"] = ( self.outcomes[index][OutcomeKeys.TOP_POINTS] - reduce_amount ) + if self.decision["amount"] < 10: self.decision["amount"] = 10 self.decision["amount"] = int(self.decision["amount"]) def calculate(self, balance: int) -> dict: diff --git a/TwitchChannelPointsMiner/classes/entities/strategies/SmartHighOdds.py b/TwitchChannelPointsMiner/classes/entities/strategies/SmartHighOdds.py index 0966fe78..88ae0b83 100644 --- a/TwitchChannelPointsMiner/classes/entities/strategies/SmartHighOdds.py +++ b/TwitchChannelPointsMiner/classes/entities/strategies/SmartHighOdds.py @@ -1,8 +1,8 @@ import logging -from TwitchChannelPointsMiner.classes.entities.Strategy import OutcomeKeys, Strategy +from TwitchChannelPointsMiner.classes.entities.Strategy import OutcomeKeys, Strategy, char_decision_as_index from TwitchChannelPointsMiner.classes.Settings import Settings -from TwitchChannelPointsMiner.utils import char_decision_as_index + logger = logging.getLogger(__name__) diff --git a/TwitchChannelPointsMiner/logger.py b/TwitchChannelPointsMiner/logger.py index 0faf7afb..ac76cc05 100644 --- a/TwitchChannelPointsMiner/logger.py +++ b/TwitchChannelPointsMiner/logger.py @@ -114,7 +114,7 @@ def format(self, record): and record.emoji_is_present is False ): record.msg = emoji.emojize( - f"{record.emoji} {record.msg.strip()}", language="alias" + f"{record.emoji} {record.msg.strip()}", use_aliases=True ) record.emoji_is_present = True