mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
fix: eliminate duplicate auto price reduction wrapper methods (#753)
This commit is contained in:
@@ -715,18 +715,6 @@ class KleinanzeigenBot(WebScrapingMixin):
|
||||
def load_ad(self, ad_cfg_orig:dict[str, Any]) -> Ad:
|
||||
return AdPartial.model_validate(ad_cfg_orig).to_ad(self.config.ad_defaults)
|
||||
|
||||
def __apply_auto_price_reduction(self, ad_cfg:Ad, _ad_cfg_orig:dict[str, Any], ad_file_relative:str) -> None:
|
||||
"""Delegate to the module-level function."""
|
||||
apply_auto_price_reduction(ad_cfg, _ad_cfg_orig, ad_file_relative)
|
||||
|
||||
def __repost_cycle_ready(self, ad_cfg:Ad, ad_file_relative:str) -> bool:
|
||||
"""Delegate to the module-level function."""
|
||||
return _repost_cycle_ready(ad_cfg, ad_file_relative)
|
||||
|
||||
def __day_delay_elapsed(self, ad_cfg:Ad, ad_file_relative:str) -> bool:
|
||||
"""Delegate to the module-level function."""
|
||||
return _day_delay_elapsed(ad_cfg, ad_file_relative)
|
||||
|
||||
async def check_and_wait_for_captcha(self, *, is_login_page:bool = True) -> None:
|
||||
try:
|
||||
captcha_timeout = self._timeout("captcha_detection")
|
||||
@@ -941,7 +929,7 @@ class KleinanzeigenBot(WebScrapingMixin):
|
||||
except ValueError:
|
||||
# On Windows, relative_to fails when paths are on different drives
|
||||
ad_file_relative = ad_file
|
||||
self.__apply_auto_price_reduction(ad_cfg, ad_cfg_orig, ad_file_relative)
|
||||
apply_auto_price_reduction(ad_cfg, ad_cfg_orig, ad_file_relative)
|
||||
|
||||
LOG.info("Publishing ad '%s'...", ad_cfg.title)
|
||||
await self.web_open(f"{self.root_url}/p-anzeige-aufgeben-schritt2.html")
|
||||
|
||||
@@ -1112,7 +1112,7 @@ class TestKleinanzeigenBotShippingOptions:
|
||||
|
||||
# Mock Path to use PureWindowsPath for testing cross-drive behavior
|
||||
with patch("kleinanzeigen_bot.Path", PureWindowsPath), \
|
||||
patch.object(test_bot, "_KleinanzeigenBot__apply_auto_price_reduction", side_effect = mock_apply_auto_price_reduction), \
|
||||
patch("kleinanzeigen_bot.apply_auto_price_reduction", side_effect = mock_apply_auto_price_reduction), \
|
||||
patch.object(test_bot, "web_open", new_callable = AsyncMock), \
|
||||
patch.object(test_bot, "delete_ad", new_callable = AsyncMock):
|
||||
# Call publish_ad and expect sentinel exception
|
||||
@@ -1156,7 +1156,7 @@ class TestKleinanzeigenBotShippingOptions:
|
||||
ad_cfg_orig = ad_cfg.model_dump()
|
||||
|
||||
# Mock the private __apply_auto_price_reduction method
|
||||
with patch.object(test_bot, "_KleinanzeigenBot__apply_auto_price_reduction") as mock_apply:
|
||||
with patch("kleinanzeigen_bot.apply_auto_price_reduction") as mock_apply:
|
||||
# Mock other dependencies
|
||||
mock_response = {"statusCode": 200, "statusMessage": "OK", "content": "{}"}
|
||||
with patch.object(test_bot, "web_find", new_callable = AsyncMock), \
|
||||
|
||||
Reference in New Issue
Block a user