fix: remove 226 unused imports across the codebase (closes #33)
Ran `ruff check --select F401 --fix` to auto-remove 221 unused imports, manually removed 4 unused `import discord` from package __init__.py files, and fixed test import for DISAPPOINTMENT_TIERS to reference canonical location. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a44d037611
commit
f64fee8d2e
2
bot.py
2
bot.py
@ -18,7 +18,7 @@ from config import get_config
|
||||
from exceptions import BotException
|
||||
from api.client import get_global_client, cleanup_global_client
|
||||
from utils.random_gen import STARTUP_WATCHING, random_from_list
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.embeds import EmbedTemplate
|
||||
|
||||
|
||||
def setup_logging():
|
||||
|
||||
@ -3,23 +3,23 @@ Admin command package for Discord Bot v2.0
|
||||
|
||||
Contains administrative commands for league management.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple, Type
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .management import AdminCommands
|
||||
from .users import UserManagementCommands
|
||||
from .league_management import LeagueManagementCommands
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.setup_admin')
|
||||
logger = logging.getLogger(f"{__name__}.setup_admin")
|
||||
|
||||
|
||||
async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
"""
|
||||
Set up admin command modules.
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (successful_loads, failed_loads, failed_modules)
|
||||
"""
|
||||
@ -28,11 +28,11 @@ async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
("UserManagementCommands", UserManagementCommands),
|
||||
("LeagueManagementCommands", LeagueManagementCommands),
|
||||
]
|
||||
|
||||
|
||||
successful = 0
|
||||
failed = 0
|
||||
failed_modules = []
|
||||
|
||||
|
||||
for cog_name, cog_class in admin_cogs:
|
||||
try:
|
||||
await bot.add_cog(cog_class(bot))
|
||||
@ -42,13 +42,15 @@ async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
logger.error(f"❌ Failed to load admin command module {cog_name}: {e}")
|
||||
failed += 1
|
||||
failed_modules.append(cog_name)
|
||||
|
||||
|
||||
# Log summary
|
||||
if failed == 0:
|
||||
logger.info(f"🎉 All {successful} admin command modules loaded successfully")
|
||||
else:
|
||||
logger.warning(f"⚠️ Admin commands loaded with issues: {successful} successful, {failed} failed")
|
||||
logger.warning(
|
||||
f"⚠️ Admin commands loaded with issues: {successful} successful, {failed} failed"
|
||||
)
|
||||
if failed_modules:
|
||||
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
@ -10,11 +10,10 @@ import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
|
||||
from config import get_config
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from utils.permissions import league_admin_only
|
||||
from views.embeds import EmbedColors, EmbedTemplate
|
||||
from views.embeds import EmbedTemplate
|
||||
from services.league_service import league_service
|
||||
from services.transaction_service import transaction_service
|
||||
from tasks.transaction_freeze import resolve_contested_transactions
|
||||
|
||||
@ -4,8 +4,7 @@ Admin User Management Commands
|
||||
User-focused administrative commands for moderation and user management.
|
||||
"""
|
||||
from typing import Optional, Union
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
@ -10,9 +10,7 @@ from discord.ext import commands
|
||||
|
||||
from services.custom_commands_service import (
|
||||
custom_commands_service,
|
||||
CustomCommandNotFoundError,
|
||||
CustomCommandExistsError,
|
||||
CustomCommandPermissionError
|
||||
CustomCommandNotFoundError
|
||||
)
|
||||
from models.custom_command import CustomCommandSearchFilters
|
||||
from utils.logging import get_contextual_logger
|
||||
@ -28,7 +26,6 @@ from views.custom_commands import (
|
||||
CustomCommandSearchModal,
|
||||
SingleCommandManagementView
|
||||
)
|
||||
from exceptions import BotException
|
||||
|
||||
|
||||
class CustomCommandsCommands(commands.Cog):
|
||||
|
||||
@ -4,14 +4,11 @@ Dice Rolling Commands
|
||||
Implements slash commands for dice rolling functionality required for gameplay.
|
||||
"""
|
||||
import random
|
||||
from typing import Optional
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from models.team import Team
|
||||
from services.team_service import team_service
|
||||
from utils import team_utils
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from utils.team_utils import get_user_major_league_team
|
||||
|
||||
@ -6,7 +6,6 @@ Manage team auto-draft queue (draft board).
|
||||
from typing import List, Optional
|
||||
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
from config import get_config
|
||||
|
||||
@ -14,7 +14,6 @@ from services.player_service import player_service
|
||||
from models.player import Player
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from exceptions import BotException
|
||||
|
||||
# Import our new view components
|
||||
from views import (
|
||||
@ -24,8 +23,7 @@ from views import (
|
||||
PlayerSelectionView,
|
||||
DetailedInfoView,
|
||||
SearchResultsView,
|
||||
PlayerSearchModal,
|
||||
PaginationView
|
||||
PlayerSearchModal
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -7,13 +7,13 @@ import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
|
||||
from services.scorebug_service import ScorebugData, ScorebugService
|
||||
from services.scorebug_service import ScorebugService
|
||||
from services.team_service import team_service
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from utils.permissions import league_only
|
||||
from utils.scorebug_helpers import create_scorebug_embed
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.embeds import EmbedTemplate
|
||||
from exceptions import SheetsException
|
||||
from .scorecard_tracker import ScorecardTracker
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ from services.help_commands_service import (
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from utils.permissions import league_admin_only
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.embeds import EmbedTemplate
|
||||
from views.help_commands import (
|
||||
HelpCommandCreateModal,
|
||||
HelpCommandEditModal,
|
||||
@ -25,7 +25,6 @@ from views.help_commands import (
|
||||
HelpCommandListView,
|
||||
create_help_topic_embed
|
||||
)
|
||||
from exceptions import BotException
|
||||
|
||||
|
||||
async def help_topic_autocomplete(
|
||||
|
||||
@ -18,9 +18,6 @@ from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
from config import get_config
|
||||
from models.current import Current
|
||||
from models.injury import Injury
|
||||
from models.player import Player
|
||||
from models.team import RosterType
|
||||
from services.player_service import player_service
|
||||
from services.injury_service import injury_service
|
||||
|
||||
@ -3,10 +3,10 @@ League command package for Discord Bot v2.0
|
||||
|
||||
Provides league-wide slash commands for standings and current state.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple, Type
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .info import LeagueInfoCommands
|
||||
@ -14,13 +14,13 @@ from .standings import StandingsCommands
|
||||
from .schedule import ScheduleCommands
|
||||
from .submit_scorecard import SubmitScorecardCommands
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.setup_league')
|
||||
logger = logging.getLogger(f"{__name__}.setup_league")
|
||||
|
||||
|
||||
async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
"""
|
||||
Set up league command modules.
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (successful_loads, failed_loads, failed_modules)
|
||||
"""
|
||||
@ -30,11 +30,11 @@ async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
("ScheduleCommands", ScheduleCommands),
|
||||
("SubmitScorecardCommands", SubmitScorecardCommands),
|
||||
]
|
||||
|
||||
|
||||
successful = 0
|
||||
failed = 0
|
||||
failed_modules = []
|
||||
|
||||
|
||||
for cog_name, cog_class in league_cogs:
|
||||
try:
|
||||
await bot.add_cog(cog_class(bot))
|
||||
@ -44,13 +44,15 @@ async def setup_league(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
logger.error(f"❌ Failed to load league command module {cog_name}: {e}")
|
||||
failed += 1
|
||||
failed_modules.append(cog_name)
|
||||
|
||||
|
||||
# Log summary
|
||||
if failed == 0:
|
||||
logger.info(f"🎉 All {successful} league command modules loaded successfully")
|
||||
else:
|
||||
logger.warning(f"⚠️ League commands loaded with issues: {successful} successful, {failed} failed")
|
||||
logger.warning(
|
||||
f"⚠️ League commands loaded with issues: {successful} successful, {failed} failed"
|
||||
)
|
||||
if failed_modules:
|
||||
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
"""
|
||||
League information commands for Discord Bot v2.0
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from services import league_service
|
||||
from config import get_config
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from exceptions import BotException
|
||||
from utils.permissions import requires_team
|
||||
from views.embeds import EmbedTemplate
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from config import get_config
|
||||
from models.team import Team
|
||||
from services.standings_service import standings_service
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
|
||||
@ -4,7 +4,7 @@ Player Image Management Commands
|
||||
Allows users to update player fancy card and headshot images for players
|
||||
on teams they own. Admins can update any player's images.
|
||||
"""
|
||||
from typing import Optional, List, Tuple
|
||||
from typing import List, Tuple
|
||||
import asyncio
|
||||
import aiohttp
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ All new code should import from services.giphy_service instead.
|
||||
from services import giphy_service
|
||||
|
||||
# Re-export tier configuration for backwards compatibility
|
||||
from services.giphy_service import DISAPPOINTMENT_TIERS
|
||||
|
||||
|
||||
def get_tier_for_seconds(seconds_elapsed):
|
||||
|
||||
@ -3,23 +3,23 @@ Team command package for Discord Bot v2.0
|
||||
|
||||
Provides team-related slash commands for the SBA league.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple, Type
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .info import TeamInfoCommands
|
||||
from .roster import TeamRosterCommands
|
||||
from .branding import BrandingCommands
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.setup_teams')
|
||||
logger = logging.getLogger(f"{__name__}.setup_teams")
|
||||
|
||||
|
||||
async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
"""
|
||||
Set up team command modules.
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (successful_loads, failed_loads, failed_modules)
|
||||
"""
|
||||
@ -28,11 +28,11 @@ async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
("TeamRosterCommands", TeamRosterCommands),
|
||||
("BrandingCommands", BrandingCommands),
|
||||
]
|
||||
|
||||
|
||||
successful = 0
|
||||
failed = 0
|
||||
failed_modules = []
|
||||
|
||||
|
||||
for cog_name, cog_class in team_cogs:
|
||||
try:
|
||||
await bot.add_cog(cog_class(bot))
|
||||
@ -42,13 +42,15 @@ async def setup_teams(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
logger.error(f"❌ Failed to load team command module {cog_name}: {e}")
|
||||
failed += 1
|
||||
failed_modules.append(cog_name)
|
||||
|
||||
|
||||
# Log summary
|
||||
if failed == 0:
|
||||
logger.info(f"🎉 All {successful} team command modules loaded successfully")
|
||||
else:
|
||||
logger.warning(f"⚠️ Team commands loaded with issues: {successful} successful, {failed} failed")
|
||||
logger.warning(
|
||||
f"⚠️ Team commands loaded with issues: {successful} successful, {failed} failed"
|
||||
)
|
||||
if failed_modules:
|
||||
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
"""
|
||||
Team information commands for Discord Bot v2.0
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional
|
||||
from config import get_config
|
||||
|
||||
@ -12,7 +11,6 @@ from services import team_service, player_service
|
||||
from models.team import RosterType, Team
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from exceptions import BotException
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.base import PaginationView
|
||||
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
"""
|
||||
Team roster commands for Discord Bot v2.0
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional, Dict, Any, List
|
||||
from typing import Dict, Any, List
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from config import get_config
|
||||
from models.player import Player
|
||||
from services import team_service, player_service
|
||||
from services import team_service
|
||||
from models.team import Team
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.decorators import logged_command
|
||||
from exceptions import BotException
|
||||
from utils.permissions import requires_team
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
|
||||
|
||||
@ -3,10 +3,10 @@ Transaction command package for Discord Bot v2.0
|
||||
|
||||
Contains transaction management commands for league operations.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Tuple, Type
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .management import TransactionCommands
|
||||
@ -14,13 +14,13 @@ from .dropadd import DropAddCommands
|
||||
from .trade import TradeCommands
|
||||
from .ilmove import ILMoveCommands
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.setup_transactions')
|
||||
logger = logging.getLogger(f"{__name__}.setup_transactions")
|
||||
|
||||
|
||||
async def setup_transactions(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
"""
|
||||
Set up transaction command modules.
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (successful_loads, failed_loads, failed_modules)
|
||||
"""
|
||||
@ -30,27 +30,33 @@ async def setup_transactions(bot: commands.Bot) -> Tuple[int, int, List[str]]:
|
||||
("TradeCommands", TradeCommands),
|
||||
("ILMoveCommands", ILMoveCommands),
|
||||
]
|
||||
|
||||
|
||||
successful = 0
|
||||
failed = 0
|
||||
failed_modules = []
|
||||
|
||||
|
||||
for cog_name, cog_class in transaction_cogs:
|
||||
try:
|
||||
await bot.add_cog(cog_class(bot))
|
||||
logger.info(f"✅ Loaded transaction command module: {cog_name}")
|
||||
successful += 1
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Failed to load transaction command module {cog_name}: {e}")
|
||||
logger.error(
|
||||
f"❌ Failed to load transaction command module {cog_name}: {e}"
|
||||
)
|
||||
failed += 1
|
||||
failed_modules.append(cog_name)
|
||||
|
||||
|
||||
# Log summary
|
||||
if failed == 0:
|
||||
logger.info(f"🎉 All {successful} transaction command modules loaded successfully")
|
||||
logger.info(
|
||||
f"🎉 All {successful} transaction command modules loaded successfully"
|
||||
)
|
||||
else:
|
||||
logger.warning(f"⚠️ Transaction commands loaded with issues: {successful} successful, {failed} failed")
|
||||
logger.warning(
|
||||
f"⚠️ Transaction commands loaded with issues: {successful} successful, {failed} failed"
|
||||
)
|
||||
if failed_modules:
|
||||
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
return successful, failed, failed_modules
|
||||
|
||||
@ -3,7 +3,7 @@ Modern /dropadd Command
|
||||
|
||||
Interactive transaction builder with real-time validation and elegant UX.
|
||||
"""
|
||||
from typing import Optional, List
|
||||
from typing import Optional
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
@ -24,7 +24,6 @@ from services.transaction_builder import (
|
||||
clear_transaction_builder
|
||||
)
|
||||
from services.player_service import player_service
|
||||
from services.team_service import team_service
|
||||
from views.transaction_embed import TransactionEmbedView, create_transaction_embed
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ from services.transaction_builder import (
|
||||
)
|
||||
from services.player_service import player_service
|
||||
from services.team_service import team_service
|
||||
from services.league_service import league_service
|
||||
from views.transaction_embed import TransactionEmbedView, create_transaction_embed
|
||||
|
||||
|
||||
|
||||
@ -16,7 +16,6 @@ from utils.autocomplete import player_autocomplete, major_league_team_autocomple
|
||||
from utils.team_utils import validate_user_has_team, get_team_by_abbrev_with_validation
|
||||
|
||||
from services.trade_builder import (
|
||||
TradeBuilder,
|
||||
get_trade_builder,
|
||||
get_trade_builder_by_team,
|
||||
clear_trade_builder,
|
||||
|
||||
@ -4,7 +4,6 @@ Trade Channel Tracker
|
||||
Provides persistent tracking of bot-created trade discussion channels using JSON file storage.
|
||||
"""
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime, UTC
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Any
|
||||
|
||||
@ -12,7 +12,7 @@ from typing import List, Optional
|
||||
from config import get_config
|
||||
from utils.decorators import logged_command
|
||||
from utils.logging import get_contextual_logger, set_discord_context
|
||||
from services.chart_service import get_chart_service, Chart
|
||||
from services.chart_service import get_chart_service
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from exceptions import BotException
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Weather command for Discord Bot v2.0
|
||||
Provides ballpark weather checks with dice rolls for gameplay.
|
||||
"""
|
||||
import random
|
||||
from typing import Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
@ -4,7 +4,7 @@ Custom Command models for Discord Bot v2.0
|
||||
Modern Pydantic models for the custom command system with full type safety.
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional
|
||||
import re
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
@ -3,7 +3,7 @@ Draft preference list model
|
||||
|
||||
Represents team draft board rankings and preferences.
|
||||
"""
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Dict, Any
|
||||
from pydantic import Field
|
||||
|
||||
from models.base import SBABaseModel
|
||||
|
||||
@ -9,8 +9,8 @@ When the API short_output=false, these fields contain full Team/Player objects.
|
||||
When short_output=true (or default), they contain integer IDs.
|
||||
We use Pydantic aliases to handle both cases.
|
||||
"""
|
||||
from typing import Optional, Any, Dict, Union
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
from typing import Optional, Any, Dict
|
||||
from pydantic import Field
|
||||
|
||||
from models.base import SBABaseModel
|
||||
from models.team import Team
|
||||
|
||||
@ -3,7 +3,7 @@ Injury model for tracking player injuries
|
||||
|
||||
Represents an injury record with game timeline and status information.
|
||||
"""
|
||||
from typing import Optional, Any, Dict
|
||||
from typing import Any
|
||||
from pydantic import Field, model_validator
|
||||
|
||||
from models.base import SBABaseModel
|
||||
|
||||
@ -3,11 +3,10 @@ Trade-specific data models for multi-team transactions.
|
||||
|
||||
Extends the base transaction system to support trades between multiple teams.
|
||||
"""
|
||||
from typing import List, Optional, Dict, Set
|
||||
from typing import List, Optional
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
from models.player import Player
|
||||
from models.team import Team, RosterType
|
||||
from services.transaction_builder import TransactionMove
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ Transaction models for SBA transaction management
|
||||
|
||||
Represents transactions and player moves based on actual API structure.
|
||||
"""
|
||||
from typing import Optional, List
|
||||
from typing import List
|
||||
from pydantic import Field
|
||||
|
||||
from models.base import SBABaseModel
|
||||
|
||||
@ -5,7 +5,6 @@ Provides common CRUD operations and error handling for all data services.
|
||||
"""
|
||||
import logging
|
||||
import hashlib
|
||||
import json
|
||||
from typing import Optional, Type, TypeVar, Generic, Dict, Any, List, Tuple
|
||||
|
||||
from api.client import get_global_client, APIClient
|
||||
|
||||
@ -3,10 +3,9 @@ Custom Commands Service for Discord Bot v2.0
|
||||
|
||||
Modern async service layer for managing custom commands with full type safety.
|
||||
"""
|
||||
import asyncio
|
||||
import math
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional, List, Dict, Any, Tuple
|
||||
from typing import Optional, List, Any, Tuple
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
from models.custom_command import (
|
||||
|
||||
@ -7,7 +7,6 @@ from typing import List, Dict, Any, Optional, Tuple
|
||||
|
||||
from utils.logging import get_contextual_logger
|
||||
from api.client import get_global_client
|
||||
from models.decision import Decision
|
||||
from models.player import Player
|
||||
from exceptions import APIException
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ from typing import Optional, List
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.draft_list import DraftList
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.DraftListService')
|
||||
|
||||
@ -46,7 +45,6 @@ class DraftListService(BaseService[DraftList]):
|
||||
Returns:
|
||||
Tuple of (items list, total count)
|
||||
"""
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
if isinstance(data, list):
|
||||
return data, len(data)
|
||||
|
||||
@ -8,7 +8,6 @@ from typing import Optional, List
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.draft_pick import DraftPick
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.DraftPickService')
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ from datetime import datetime, timedelta
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.draft_data import DraftData
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.DraftService')
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import asyncio
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from config import get_config
|
||||
from exceptions import SheetsException
|
||||
from services.sheets_service import SheetsService
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ Modern async service layer for managing help commands with full type safety.
|
||||
Allows admins and help editors to create custom help topics for league documentation,
|
||||
resources, FAQs, links, and guides.
|
||||
"""
|
||||
import math
|
||||
from typing import Optional, List
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ from typing import Optional, List
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.injury import Injury
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.InjuryService')
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ Handles roster operations and validation.
|
||||
import logging
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.roster import TeamRoster
|
||||
from models.player import Player
|
||||
from models.transaction import RosterValidation
|
||||
|
||||
@ -6,9 +6,7 @@ Handles game schedule and results retrieval and processing.
|
||||
import logging
|
||||
from typing import Optional, List, Dict, Tuple
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.game import Game
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.ScheduleService')
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Scorebug Service
|
||||
Handles reading live game data from Google Sheets scorecards for real-time score displays.
|
||||
"""
|
||||
import asyncio
|
||||
from typing import Dict, List, Any, Optional
|
||||
from typing import Dict, Any, Optional
|
||||
import pygsheets
|
||||
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
@ -6,7 +6,6 @@ Handles team standings retrieval and processing.
|
||||
import logging
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.standings import TeamStandings
|
||||
from exceptions import APIException
|
||||
|
||||
|
||||
@ -4,12 +4,10 @@ Statistics service for Discord Bot v2.0
|
||||
Handles batting and pitching statistics retrieval and processing.
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional, List
|
||||
from typing import Optional
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.batting_stats import BattingStats
|
||||
from models.pitching_stats import PitchingStats
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.StatsService')
|
||||
|
||||
|
||||
@ -4,18 +4,16 @@ Trade Builder Service
|
||||
Extends the TransactionBuilder to support multi-team trades and player exchanges.
|
||||
"""
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Set, Tuple
|
||||
from typing import Dict, List, Optional, Set
|
||||
from datetime import datetime, timezone
|
||||
import uuid
|
||||
|
||||
from config import get_config
|
||||
from models.trade import Trade, TradeParticipant, TradeMove, TradeStatus
|
||||
from models.trade import Trade, TradeMove, TradeStatus
|
||||
from models.team import Team, RosterType
|
||||
from models.player import Player
|
||||
from services.transaction_builder import TransactionBuilder, RosterValidationResult, TransactionMove
|
||||
from services.team_service import team_service
|
||||
from services.roster_service import roster_service
|
||||
from services.league_service import league_service
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.TradeBuilder')
|
||||
|
||||
|
||||
@ -4,8 +4,7 @@ Transaction Builder Service
|
||||
Handles the complex logic for building multi-move transactions interactively.
|
||||
"""
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Tuple, Set
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Optional
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
|
||||
@ -14,8 +13,6 @@ from models.transaction import Transaction
|
||||
from models.team import Team
|
||||
from models.player import Player
|
||||
from models.roster import TeamRoster
|
||||
from services.player_service import player_service
|
||||
from services.team_service import team_service
|
||||
from services.roster_service import roster_service
|
||||
from services.transaction_service import transaction_service
|
||||
from services.league_service import league_service
|
||||
|
||||
@ -4,12 +4,11 @@ Transaction service for Discord Bot v2.0
|
||||
Handles transaction CRUD operations and business logic.
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional, List, Tuple
|
||||
from typing import Optional, List
|
||||
from datetime import datetime, UTC
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.transaction import Transaction, RosterValidation
|
||||
from models.roster import TeamRoster
|
||||
from exceptions import APIException
|
||||
|
||||
logger = logging.getLogger(f'{__name__}.TransactionService')
|
||||
|
||||
@ -5,7 +5,7 @@ Modern automated cleanup system with better notifications and logging.
|
||||
"""
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List
|
||||
|
||||
import discord
|
||||
from discord.ext import commands, tasks
|
||||
@ -13,7 +13,7 @@ from discord.ext import commands, tasks
|
||||
from services.custom_commands_service import custom_commands_service
|
||||
from models.custom_command import CustomCommand
|
||||
from utils.logging import get_contextual_logger
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.embeds import EmbedTemplate
|
||||
from config import get_config
|
||||
|
||||
|
||||
|
||||
@ -4,9 +4,7 @@ Draft Monitor Task for Discord Bot v2.0
|
||||
Automated background task for draft timer monitoring, warnings, and auto-draft.
|
||||
Self-terminates when draft timer is disabled to conserve resources.
|
||||
"""
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
import discord
|
||||
from discord.ext import commands, tasks
|
||||
@ -15,12 +13,9 @@ from services.draft_service import draft_service
|
||||
from services.draft_pick_service import draft_pick_service
|
||||
from services.draft_list_service import draft_list_service
|
||||
from services.draft_sheet_service import get_draft_sheet_service
|
||||
from services.player_service import player_service
|
||||
from services.team_service import team_service
|
||||
from services.roster_service import roster_service
|
||||
from utils.logging import get_contextual_logger
|
||||
from utils.helpers import get_team_salary_cap
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.draft_views import create_on_clock_announcement_embed
|
||||
from config import get_config
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Live Scorebug Tracker
|
||||
Background task that monitors published scorecards and updates live score displays.
|
||||
"""
|
||||
import asyncio
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
import discord
|
||||
from discord.ext import tasks, commands
|
||||
|
||||
@ -16,7 +16,6 @@ from services.scorebug_service import ScorebugData, ScorebugService
|
||||
from services.team_service import team_service
|
||||
from commands.gameplay.scorecard_tracker import ScorecardTracker
|
||||
from commands.voice.tracker import VoiceChannelTracker
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from config import get_config
|
||||
from exceptions import SheetsException
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ Pytest configuration and fixtures for Discord Bot v2.0 tests.
|
||||
|
||||
This file provides test isolation and shared fixtures.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import pytest
|
||||
@ -27,12 +28,14 @@ def reset_singleton_state():
|
||||
# Reset transaction builder caches
|
||||
try:
|
||||
from services.transaction_builder import _transaction_builders
|
||||
|
||||
_transaction_builders.clear()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from services.trade_builder import _trade_builders, _team_to_trade_key
|
||||
|
||||
_trade_builders.clear()
|
||||
_team_to_trade_key.clear()
|
||||
except ImportError:
|
||||
@ -40,8 +43,9 @@ def reset_singleton_state():
|
||||
|
||||
# Reset config singleton to ensure clean state
|
||||
try:
|
||||
from config import _config
|
||||
from config import _config # noqa: F401
|
||||
import config as cfg
|
||||
|
||||
cfg._config = None
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
|
||||
@ -5,10 +5,10 @@ Provides factory functions to create test instances of models with sensible defa
|
||||
This eliminates the need for ad-hoc fixture creation and makes tests resilient
|
||||
to model changes.
|
||||
"""
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional
|
||||
|
||||
from models.player import Player
|
||||
from models.team import Team, RosterType
|
||||
from models.team import Team
|
||||
from models.transaction import Transaction
|
||||
from models.game import Game
|
||||
from models.current import Current
|
||||
|
||||
@ -3,7 +3,6 @@ API client tests using aioresponses for clean HTTP mocking
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
import aiohttp
|
||||
from unittest.mock import MagicMock, patch
|
||||
from aioresponses import aioresponses
|
||||
|
||||
|
||||
@ -6,13 +6,12 @@ import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from discord import app_commands
|
||||
|
||||
from commands.utilities.charts import (
|
||||
ChartCommands, ChartManageGroup, ChartCategoryGroup,
|
||||
chart_autocomplete, category_autocomplete
|
||||
chart_autocomplete
|
||||
)
|
||||
from services.chart_service import ChartService, Chart, get_chart_service
|
||||
from services.chart_service import ChartService, Chart
|
||||
from exceptions import BotException
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from commands.dice.rolls import DiceRollCommands
|
||||
from utils.dice_utils import DiceRoll, parse_and_roll_multiple_dice, parse_and_roll_single_dice
|
||||
from utils.dice_utils import DiceRoll, parse_and_roll_multiple_dice
|
||||
|
||||
|
||||
class TestDiceRollCommands:
|
||||
|
||||
@ -6,14 +6,10 @@ Validates the Discord command interface, autocomplete, and user interactions.
|
||||
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
from commands.transactions.dropadd import DropAddCommands
|
||||
from services.transaction_builder import TransactionBuilder
|
||||
from models.team import RosterType
|
||||
from models.team import Team
|
||||
from models.player import Player
|
||||
from tests.factories import PlayerFactory, TeamFactory
|
||||
|
||||
|
||||
|
||||
@ -15,8 +15,6 @@ from commands.profile.images import (
|
||||
can_edit_player_image,
|
||||
ImageCommands
|
||||
)
|
||||
from models.player import Player
|
||||
from models.team import Team
|
||||
from tests.factories import PlayerFactory, TeamFactory
|
||||
|
||||
|
||||
|
||||
@ -7,12 +7,11 @@ Tests cover:
|
||||
- Message listener (detection logic)
|
||||
- Info command (response formatting)
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch, mock_open
|
||||
from datetime import datetime, UTC
|
||||
from aioresponses import aioresponses
|
||||
|
||||
# Import modules to test
|
||||
@ -21,15 +20,16 @@ from commands.soak.giphy_service import (
|
||||
get_random_phrase_for_tier,
|
||||
get_tier_description,
|
||||
get_disappointment_gif,
|
||||
DISAPPOINTMENT_TIERS
|
||||
)
|
||||
from services.giphy_service import DISAPPOINTMENT_TIERS
|
||||
from commands.soak.tracker import SoakTracker
|
||||
|
||||
|
||||
# Listener uses simple string matching: ' soak' in msg_text.lower()
|
||||
# Define helper function that mimics the listener's detection logic
|
||||
def soak_detected(text: str) -> bool:
|
||||
"""Check if soak mention is detected using listener's logic."""
|
||||
return ' soak' in text.lower()
|
||||
return " soak" in text.lower()
|
||||
|
||||
|
||||
class TestGiphyService:
|
||||
@ -38,78 +38,78 @@ class TestGiphyService:
|
||||
def test_tier_determination_first_ever(self):
|
||||
"""Test tier determination for first ever soak."""
|
||||
tier = get_tier_for_seconds(None)
|
||||
assert tier == 'first_ever'
|
||||
assert tier == "first_ever"
|
||||
|
||||
def test_tier_determination_maximum_disappointment(self):
|
||||
"""Test tier 1: 0-30 minutes (maximum disappointment)."""
|
||||
# 15 minutes
|
||||
tier = get_tier_for_seconds(900)
|
||||
assert tier == 'tier_1'
|
||||
assert tier == "tier_1"
|
||||
|
||||
# 30 minutes (boundary)
|
||||
tier = get_tier_for_seconds(1800)
|
||||
assert tier == 'tier_1'
|
||||
assert tier == "tier_1"
|
||||
|
||||
def test_tier_determination_severe_disappointment(self):
|
||||
"""Test tier 2: 30min-2hrs (severe disappointment)."""
|
||||
# 1 hour
|
||||
tier = get_tier_for_seconds(3600)
|
||||
assert tier == 'tier_2'
|
||||
assert tier == "tier_2"
|
||||
|
||||
# 2 hours (boundary)
|
||||
tier = get_tier_for_seconds(7200)
|
||||
assert tier == 'tier_2'
|
||||
assert tier == "tier_2"
|
||||
|
||||
def test_tier_determination_strong_disappointment(self):
|
||||
"""Test tier 3: 2-6 hours (strong disappointment)."""
|
||||
# 4 hours
|
||||
tier = get_tier_for_seconds(14400)
|
||||
assert tier == 'tier_3'
|
||||
assert tier == "tier_3"
|
||||
|
||||
# 6 hours (boundary)
|
||||
tier = get_tier_for_seconds(21600)
|
||||
assert tier == 'tier_3'
|
||||
assert tier == "tier_3"
|
||||
|
||||
def test_tier_determination_moderate_disappointment(self):
|
||||
"""Test tier 4: 6-24 hours (moderate disappointment)."""
|
||||
# 12 hours
|
||||
tier = get_tier_for_seconds(43200)
|
||||
assert tier == 'tier_4'
|
||||
assert tier == "tier_4"
|
||||
|
||||
# 24 hours (boundary)
|
||||
tier = get_tier_for_seconds(86400)
|
||||
assert tier == 'tier_4'
|
||||
assert tier == "tier_4"
|
||||
|
||||
def test_tier_determination_mild_disappointment(self):
|
||||
"""Test tier 5: 1-7 days (mild disappointment)."""
|
||||
# 3 days
|
||||
tier = get_tier_for_seconds(259200)
|
||||
assert tier == 'tier_5'
|
||||
assert tier == "tier_5"
|
||||
|
||||
# 7 days (boundary)
|
||||
tier = get_tier_for_seconds(604800)
|
||||
assert tier == 'tier_5'
|
||||
assert tier == "tier_5"
|
||||
|
||||
def test_tier_determination_minimal_disappointment(self):
|
||||
"""Test tier 6: 7+ days (minimal disappointment)."""
|
||||
# 10 days
|
||||
tier = get_tier_for_seconds(864000)
|
||||
assert tier == 'tier_6'
|
||||
assert tier == "tier_6"
|
||||
|
||||
# 30 days
|
||||
tier = get_tier_for_seconds(2592000)
|
||||
assert tier == 'tier_6'
|
||||
assert tier == "tier_6"
|
||||
|
||||
def test_random_phrase_selection(self):
|
||||
"""Test that random phrase selection returns valid phrases."""
|
||||
for tier_key in DISAPPOINTMENT_TIERS.keys():
|
||||
phrase = get_random_phrase_for_tier(tier_key)
|
||||
assert phrase in DISAPPOINTMENT_TIERS[tier_key]['phrases']
|
||||
assert phrase in DISAPPOINTMENT_TIERS[tier_key]["phrases"]
|
||||
|
||||
def test_tier_description_retrieval(self):
|
||||
"""Test tier description retrieval."""
|
||||
assert get_tier_description('tier_1') == "Maximum Disappointment"
|
||||
assert get_tier_description('first_ever') == "The Beginning"
|
||||
assert get_tier_description("tier_1") == "Maximum Disappointment"
|
||||
assert get_tier_description("first_ever") == "The Beginning"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_disappointment_gif_success(self):
|
||||
@ -122,22 +122,22 @@ class TestGiphyService:
|
||||
# Mock successful Giphy response with correct response structure
|
||||
# The service looks for data.images.original.url, not data.url
|
||||
m.get(
|
||||
re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'),
|
||||
re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"),
|
||||
payload={
|
||||
'data': {
|
||||
'images': {
|
||||
'original': {
|
||||
'url': 'https://media.giphy.com/media/test123/giphy.gif'
|
||||
"data": {
|
||||
"images": {
|
||||
"original": {
|
||||
"url": "https://media.giphy.com/media/test123/giphy.gif"
|
||||
}
|
||||
},
|
||||
'title': 'Disappointed Reaction'
|
||||
"title": "Disappointed Reaction",
|
||||
}
|
||||
},
|
||||
status=200
|
||||
status=200,
|
||||
)
|
||||
|
||||
gif_url = await get_disappointment_gif('tier_1')
|
||||
assert gif_url == 'https://media.giphy.com/media/test123/giphy.gif'
|
||||
gif_url = await get_disappointment_gif("tier_1")
|
||||
assert gif_url == "https://media.giphy.com/media/test123/giphy.gif"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_disappointment_gif_filters_trump(self):
|
||||
@ -151,37 +151,37 @@ class TestGiphyService:
|
||||
# First response is Trump GIF (should be filtered)
|
||||
# Uses correct response structure with images.original.url
|
||||
m.get(
|
||||
re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'),
|
||||
re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"),
|
||||
payload={
|
||||
'data': {
|
||||
'images': {
|
||||
'original': {
|
||||
'url': 'https://media.giphy.com/media/trump123/giphy.gif'
|
||||
"data": {
|
||||
"images": {
|
||||
"original": {
|
||||
"url": "https://media.giphy.com/media/trump123/giphy.gif"
|
||||
}
|
||||
},
|
||||
'title': 'Donald Trump Disappointed'
|
||||
"title": "Donald Trump Disappointed",
|
||||
}
|
||||
},
|
||||
status=200
|
||||
status=200,
|
||||
)
|
||||
# Second response is acceptable
|
||||
m.get(
|
||||
re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'),
|
||||
re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"),
|
||||
payload={
|
||||
'data': {
|
||||
'images': {
|
||||
'original': {
|
||||
'url': 'https://media.giphy.com/media/good456/giphy.gif'
|
||||
"data": {
|
||||
"images": {
|
||||
"original": {
|
||||
"url": "https://media.giphy.com/media/good456/giphy.gif"
|
||||
}
|
||||
},
|
||||
'title': 'Disappointed Reaction'
|
||||
"title": "Disappointed Reaction",
|
||||
}
|
||||
},
|
||||
status=200
|
||||
status=200,
|
||||
)
|
||||
|
||||
gif_url = await get_disappointment_gif('tier_1')
|
||||
assert gif_url == 'https://media.giphy.com/media/good456/giphy.gif'
|
||||
gif_url = await get_disappointment_gif("tier_1")
|
||||
assert gif_url == "https://media.giphy.com/media/good456/giphy.gif"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_disappointment_gif_api_failure(self):
|
||||
@ -189,12 +189,12 @@ class TestGiphyService:
|
||||
with aioresponses() as m:
|
||||
# Mock API failure for all requests
|
||||
m.get(
|
||||
re.compile(r'https://api\.giphy\.com/v1/gifs/translate\?.*'),
|
||||
re.compile(r"https://api\.giphy\.com/v1/gifs/translate\?.*"),
|
||||
status=500,
|
||||
repeat=True
|
||||
repeat=True,
|
||||
)
|
||||
|
||||
gif_url = await get_disappointment_gif('tier_1')
|
||||
gif_url = await get_disappointment_gif("tier_1")
|
||||
assert gif_url is None
|
||||
|
||||
|
||||
@ -224,13 +224,13 @@ class TestSoakTracker:
|
||||
"username": "testuser",
|
||||
"display_name": "Test User",
|
||||
"channel_id": "456",
|
||||
"message_id": "789"
|
||||
"message_id": "789",
|
||||
},
|
||||
"total_count": 5,
|
||||
"history": []
|
||||
"history": [],
|
||||
}
|
||||
|
||||
with open(temp_tracker_file, 'w') as f:
|
||||
with open(temp_tracker_file, "w") as f:
|
||||
json.dump(existing_data, f)
|
||||
|
||||
tracker = SoakTracker(temp_tracker_file)
|
||||
@ -247,15 +247,15 @@ class TestSoakTracker:
|
||||
username="testuser",
|
||||
display_name="Test User",
|
||||
channel_id=789012,
|
||||
message_id=345678
|
||||
message_id=345678,
|
||||
)
|
||||
|
||||
assert tracker.get_soak_count() == 1
|
||||
|
||||
last_soak = tracker.get_last_soak()
|
||||
assert last_soak is not None
|
||||
assert last_soak['user_id'] == '123456'
|
||||
assert last_soak['username'] == 'testuser'
|
||||
assert last_soak["user_id"] == "123456"
|
||||
assert last_soak["username"] == "testuser"
|
||||
|
||||
def test_record_multiple_soaks(self, temp_tracker_file):
|
||||
"""Test recording multiple soaks maintains history."""
|
||||
@ -268,7 +268,7 @@ class TestSoakTracker:
|
||||
username=f"user{i}",
|
||||
display_name=f"User {i}",
|
||||
channel_id=100,
|
||||
message_id=200 + i
|
||||
message_id=200 + i,
|
||||
)
|
||||
|
||||
assert tracker.get_soak_count() == 3
|
||||
@ -276,8 +276,8 @@ class TestSoakTracker:
|
||||
history = tracker.get_history()
|
||||
assert len(history) == 3
|
||||
# History should be newest first
|
||||
assert history[0]['user_id'] == '2'
|
||||
assert history[2]['user_id'] == '0'
|
||||
assert history[0]["user_id"] == "2"
|
||||
assert history[2]["user_id"] == "0"
|
||||
|
||||
def test_get_time_since_last_soak(self, temp_tracker_file):
|
||||
"""Test time calculation since last soak."""
|
||||
@ -292,7 +292,7 @@ class TestSoakTracker:
|
||||
username="test",
|
||||
display_name="Test",
|
||||
channel_id=456,
|
||||
message_id=789
|
||||
message_id=789,
|
||||
)
|
||||
|
||||
# Time since should be very small (just recorded)
|
||||
@ -311,7 +311,7 @@ class TestSoakTracker:
|
||||
username=f"user{i}",
|
||||
display_name=f"User {i}",
|
||||
channel_id=100,
|
||||
message_id=200 + i
|
||||
message_id=200 + i,
|
||||
)
|
||||
|
||||
history = tracker.get_history(limit=9999)
|
||||
@ -380,5 +380,9 @@ class TestInfoCommand:
|
||||
channel_id = 987654321
|
||||
message_id = 111222333
|
||||
|
||||
expected_url = f"https://discord.com/channels/{guild_id}/{channel_id}/{message_id}"
|
||||
assert expected_url == "https://discord.com/channels/123456789/987654321/111222333"
|
||||
expected_url = (
|
||||
f"https://discord.com/channels/{guild_id}/{channel_id}/{message_id}"
|
||||
)
|
||||
assert (
|
||||
expected_url == "https://discord.com/channels/123456789/987654321/111222333"
|
||||
)
|
||||
|
||||
@ -14,7 +14,6 @@ from commands.teams.branding import (
|
||||
BrandingCommands
|
||||
)
|
||||
from models.team import Team
|
||||
from tests.factories import TeamFactory
|
||||
|
||||
|
||||
class TestHexColorValidation:
|
||||
|
||||
@ -3,8 +3,6 @@ Tests for voice channel commands
|
||||
|
||||
Validates voice channel creation, cleanup, and migration message functionality.
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import tempfile
|
||||
from datetime import datetime, timedelta, UTC
|
||||
from pathlib import Path
|
||||
|
||||
@ -8,7 +8,6 @@ import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from config import BotConfig
|
||||
from exceptions import ConfigurationException
|
||||
|
||||
|
||||
class TestBotConfig:
|
||||
|
||||
@ -3,7 +3,6 @@ Tests for application configuration
|
||||
|
||||
Validates that config values have sensible defaults.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from config import get_config, PITCHER_POSITIONS, POSITION_FIELDERS, ALL_POSITIONS
|
||||
|
||||
|
||||
@ -6,18 +6,15 @@ Tests complete workflows from command invocation through transaction submission.
|
||||
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from datetime import datetime
|
||||
|
||||
from commands.transactions.dropadd import DropAddCommands
|
||||
from services.transaction_builder import (
|
||||
TransactionBuilder,
|
||||
TransactionMove,
|
||||
get_transaction_builder,
|
||||
clear_transaction_builder,
|
||||
)
|
||||
from models.team import RosterType
|
||||
from views.transaction_embed import TransactionEmbedView, SubmitConfirmationModal
|
||||
from models.team import Team
|
||||
from views.transaction_embed import SubmitConfirmationModal
|
||||
from models.player import Player
|
||||
from models.roster import TeamRoster
|
||||
from models.transaction import Transaction
|
||||
|
||||
@ -4,7 +4,6 @@ Tests for SBA data models
|
||||
Validates model creation, validation, and business logic.
|
||||
"""
|
||||
import pytest
|
||||
from datetime import datetime
|
||||
|
||||
from models import Team, Player, Current, DraftPick, DraftData, DraftList
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ Tests for trade-specific models.
|
||||
Tests the Trade, TradeParticipant, and TradeMove models to ensure proper
|
||||
validation and behavior for multi-team trades.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from models.trade import Trade, TradeParticipant, TradeMove, TradeStatus
|
||||
|
||||
@ -5,11 +5,8 @@ Validates transaction model creation, validation, and business logic.
|
||||
"""
|
||||
import pytest
|
||||
import copy
|
||||
from datetime import datetime
|
||||
|
||||
from models.transaction import Transaction, RosterValidation
|
||||
from models.player import Player
|
||||
from models.team import Team
|
||||
|
||||
|
||||
class TestTransaction:
|
||||
|
||||
@ -6,7 +6,6 @@ from unittest.mock import AsyncMock
|
||||
|
||||
from services.base_service import BaseService
|
||||
from models.base import SBABaseModel
|
||||
from exceptions import APIException
|
||||
|
||||
|
||||
class MockModel(SBABaseModel):
|
||||
|
||||
@ -4,23 +4,17 @@ Tests for Custom Commands Service in Discord Bot v2.0
|
||||
Fixed version with proper mocking following established patterns.
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from typing import List
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from services.custom_commands_service import (
|
||||
CustomCommandsService,
|
||||
CustomCommandNotFoundError,
|
||||
CustomCommandExistsError,
|
||||
CustomCommandPermissionError
|
||||
CustomCommandExistsError
|
||||
)
|
||||
from models.custom_command import (
|
||||
CustomCommand,
|
||||
CustomCommandCreator,
|
||||
CustomCommandSearchFilters,
|
||||
CustomCommandSearchResult,
|
||||
CustomCommandStats
|
||||
CustomCommandCreator
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@ Tests the Google Sheets integration for draft pick tracking.
|
||||
Uses mocked pygsheets to avoid actual API calls.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from typing import Tuple, List
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from services.draft_sheet_service import DraftSheetService, get_draft_sheet_service
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Tests for Help Commands Service in Discord Bot v2.0
|
||||
Comprehensive tests for help commands CRUD operations and business logic.
|
||||
"""
|
||||
import pytest
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from services.help_commands_service import (
|
||||
|
||||
@ -12,7 +12,7 @@ rather than trying to mock HTTP responses, since the service uses BaseService
|
||||
which manages its own client instance.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from services.injury_service import InjuryService
|
||||
from models.injury import Injury
|
||||
|
||||
@ -10,7 +10,6 @@ from typing import Dict, Any, List
|
||||
|
||||
from services.league_service import LeagueService, league_service
|
||||
from models.current import Current
|
||||
from exceptions import APIException
|
||||
|
||||
|
||||
class TestLeagueService:
|
||||
|
||||
@ -19,7 +19,7 @@ from services.trade_builder import (
|
||||
_team_to_trade_key,
|
||||
)
|
||||
from models.trade import TradeStatus
|
||||
from models.team import RosterType, Team
|
||||
from models.team import RosterType
|
||||
from tests.factories import PlayerFactory, TeamFactory
|
||||
|
||||
|
||||
|
||||
@ -4,8 +4,7 @@ Tests for TransactionService
|
||||
Validates transaction service functionality, API interaction, and business logic.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from datetime import datetime
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from services.transaction_service import TransactionService, transaction_service
|
||||
from models.transaction import Transaction, RosterValidation
|
||||
|
||||
@ -5,7 +5,6 @@ Validates transaction building, roster validation, and move management.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from datetime import datetime
|
||||
|
||||
from services.transaction_builder import (
|
||||
TransactionBuilder,
|
||||
@ -19,7 +18,6 @@ from models.team import Team
|
||||
from models.player import Player
|
||||
from models.roster import TeamRoster
|
||||
from models.transaction import Transaction
|
||||
from tests.factories import PlayerFactory, TeamFactory
|
||||
|
||||
|
||||
class TestTransactionBuilder:
|
||||
|
||||
@ -4,10 +4,7 @@ Tests for Custom Command Cleanup Tasks in Discord Bot v2.0
|
||||
Fixed version that tests cleanup logic without Discord task infrastructure.
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||
from typing import List
|
||||
|
||||
from models.custom_command import (
|
||||
CustomCommand,
|
||||
|
||||
@ -9,8 +9,7 @@ Validates the automated weekly freeze system for transactions, including:
|
||||
- Transaction processing
|
||||
"""
|
||||
import pytest
|
||||
from datetime import datetime, timezone, UTC
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch, call
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from typing import List
|
||||
|
||||
from tasks.transaction_freeze import (
|
||||
|
||||
@ -9,7 +9,6 @@ import asyncio
|
||||
|
||||
from models.transaction import Transaction, RosterValidation
|
||||
from models.team import Team
|
||||
from models.roster import TeamRoster
|
||||
from services.transaction_service import transaction_service
|
||||
from commands.transactions.management import TransactionCommands
|
||||
from tests.factories import TeamFactory
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
Tests for the logging decorator utility
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
import discord
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from utils.decorators import logged_command
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
@ -12,7 +12,6 @@ Why these tests matter:
|
||||
- Proper fallback behavior ensures backwards compatibility
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from utils.helpers import (
|
||||
DEFAULT_SALARY_CAP,
|
||||
SALARY_CAP_TOLERANCE,
|
||||
|
||||
@ -6,7 +6,6 @@ Tests contextual logging, operation tracing, and Discord context management.
|
||||
import pytest
|
||||
import time
|
||||
from unittest.mock import Mock, patch
|
||||
from typing import Dict, Any
|
||||
|
||||
from utils.logging import (
|
||||
get_contextual_logger,
|
||||
|
||||
@ -4,7 +4,6 @@ Tests for scorebug_helpers utility functions.
|
||||
Tests the create_team_progress_bar function to ensure correct
|
||||
win probability visualization for home and away teams.
|
||||
"""
|
||||
import pytest
|
||||
from utils.scorebug_helpers import create_team_progress_bar
|
||||
|
||||
|
||||
|
||||
@ -4,17 +4,14 @@ Tests for Custom Command Views in Discord Bot v2.0
|
||||
Fixed version with proper async handling and model validation.
|
||||
"""
|
||||
import pytest
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||
from typing import List
|
||||
from unittest.mock import AsyncMock, Mock
|
||||
|
||||
import discord
|
||||
|
||||
from models.custom_command import (
|
||||
CustomCommand,
|
||||
CustomCommandCreator,
|
||||
CustomCommandSearchResult
|
||||
CustomCommandCreator
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -5,13 +5,11 @@ Tests week and game validation for BatterInjuryModal and PitcherRestModal,
|
||||
including regular season and playoff round validation.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch, PropertyMock
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import AsyncMock, MagicMock, patch, PropertyMock
|
||||
|
||||
import discord
|
||||
|
||||
from views.modals import BatterInjuryModal, PitcherRestModal
|
||||
from views.embeds import EmbedTemplate
|
||||
from models.player import Player
|
||||
|
||||
|
||||
|
||||
@ -11,17 +11,14 @@ import discord
|
||||
from views.transaction_embed import (
|
||||
TransactionEmbedView,
|
||||
RemoveMoveView,
|
||||
RemoveMoveSelect,
|
||||
SubmitConfirmationModal,
|
||||
create_transaction_embed,
|
||||
)
|
||||
from services.transaction_builder import (
|
||||
TransactionBuilder,
|
||||
TransactionMove,
|
||||
RosterValidationResult,
|
||||
)
|
||||
from models.team import Team, RosterType
|
||||
from models.player import Player
|
||||
from models.team import Team
|
||||
|
||||
|
||||
class TestTransactionEmbedView:
|
||||
|
||||
@ -3,7 +3,7 @@ Autocomplete Utilities
|
||||
|
||||
Shared autocomplete functions for Discord slash commands.
|
||||
"""
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ Helper functions for Discord Bot v2.0
|
||||
|
||||
Contains utility functions for salary cap calculations and other common operations.
|
||||
"""
|
||||
from typing import Union
|
||||
from config import get_config
|
||||
|
||||
# Get default values from config
|
||||
|
||||
@ -5,14 +5,13 @@ Provides functions for posting injury information to Discord channels:
|
||||
- #injury-log: Two embeds showing current injuries by team and by return week
|
||||
- #sba-network-news: Individual injury announcements
|
||||
"""
|
||||
from typing import Optional, Dict, List, Any
|
||||
from typing import Dict, List
|
||||
from collections import defaultdict
|
||||
|
||||
import discord
|
||||
|
||||
from config import get_config
|
||||
from models.player import Player
|
||||
from models.team import Team
|
||||
from services.injury_service import injury_service
|
||||
from services.team_service import team_service
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
|
||||
@ -4,7 +4,7 @@ Random content generation utilities for Discord Bot v2.0
|
||||
Provides fun, random content for bot interactions and responses.
|
||||
"""
|
||||
import random
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
logger = get_contextual_logger(__name__)
|
||||
|
||||
@ -4,7 +4,6 @@ Scorebug Display Helpers
|
||||
Utility functions for formatting and displaying scorebug information.
|
||||
"""
|
||||
import discord
|
||||
from typing import Optional
|
||||
|
||||
from views.embeds import EmbedColors
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import discord
|
||||
from config import get_config
|
||||
from models.transaction import Transaction
|
||||
from models.team import Team
|
||||
from models.trade import Trade
|
||||
from services.trade_builder import TradeBuilder
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
@ -3,12 +3,10 @@ Base View Classes for Discord Bot v2.0
|
||||
|
||||
Provides foundational view components with consistent styling and behavior.
|
||||
"""
|
||||
import logging
|
||||
from typing import List, Optional, Any, Callable, Awaitable, Union
|
||||
from typing import List, Optional, Any, Callable, Awaitable
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
|
||||
@ -4,17 +4,14 @@ Common Discord View Components for Bot v2.0
|
||||
Specialized views for frequent use cases including player/team selection,
|
||||
detailed information displays, and interactive menus.
|
||||
"""
|
||||
from typing import Optional, List, Dict, Any, Callable, Awaitable, Union
|
||||
import asyncio
|
||||
from typing import Optional, List, Dict, Any, Callable, Awaitable
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .base import BaseView, PaginationView, SelectMenuView
|
||||
from .embeds import SBAEmbedTemplate, EmbedTemplate, EmbedColors
|
||||
from models.player import Player
|
||||
from models.team import Team
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
|
||||
class PlayerSelectionView(SelectMenuView):
|
||||
|
||||
@ -3,15 +3,13 @@ Custom Command Views for Discord Bot v2.0
|
||||
|
||||
Interactive views and modals for the modern custom command system.
|
||||
"""
|
||||
from typing import Optional, List, Callable, Awaitable
|
||||
from typing import Optional, List
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from views.base import BaseView, ConfirmationView, PaginationView
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.modals import BaseModal
|
||||
from models.custom_command import CustomCommand, CustomCommandSearchResult
|
||||
from utils.logging import get_contextual_logger
|
||||
from services.custom_commands_service import custom_commands_service
|
||||
from exceptions import BotException
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ Draft Views for Discord Bot v2.0
|
||||
Provides embeds and UI components for draft system.
|
||||
"""
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
import discord
|
||||
|
||||
@ -15,7 +14,6 @@ from models.player import Player
|
||||
from models.draft_list import DraftList
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from utils.draft_helpers import format_pick_display, get_round_name
|
||||
from config import get_config
|
||||
|
||||
|
||||
async def create_on_the_clock_embed(
|
||||
|
||||
@ -3,7 +3,7 @@ Embed Templates for Discord Bot v2.0
|
||||
|
||||
Provides consistent embed styling and templates for common use cases.
|
||||
"""
|
||||
from typing import Optional, Union, Any, List
|
||||
from typing import Optional, Union, List
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@ -6,12 +6,10 @@ Interactive views and modals for the custom help system.
|
||||
from typing import Optional, List
|
||||
import discord
|
||||
|
||||
from views.base import BaseView, ConfirmationView, PaginationView
|
||||
from views.base import BaseView
|
||||
from views.embeds import EmbedTemplate, EmbedColors
|
||||
from views.modals import BaseModal
|
||||
from models.help_command import HelpCommand, HelpCommandSearchResult
|
||||
from utils.logging import get_contextual_logger
|
||||
from exceptions import BotException
|
||||
from models.help_command import HelpCommand
|
||||
|
||||
|
||||
class HelpCommandCreateModal(BaseModal):
|
||||
|
||||
@ -7,9 +7,8 @@ from typing import Optional, Callable, Awaitable, Dict, Any, List
|
||||
import re
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
from .embeds import EmbedTemplate, EmbedColors
|
||||
from .embeds import EmbedTemplate
|
||||
from utils.logging import get_contextual_logger
|
||||
|
||||
|
||||
@ -738,7 +737,6 @@ class PitcherRestModal(BaseModal):
|
||||
"""Handle pitcher rest input and log injury."""
|
||||
from services.player_service import player_service
|
||||
from services.injury_service import injury_service
|
||||
from models.injury import Injury
|
||||
from config import get_config
|
||||
import math
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user