From 1aa08be4ec3b8f0e1ce90b488ab6b1764e830d40 Mon Sep 17 00:00:00 2001 From: Jens <1742418+1cu@users.noreply.github.com> Date: Sun, 28 Dec 2025 20:34:03 +0100 Subject: [PATCH] fix: eliminate duplicate auto price reduction wrapper methods (#753) --- src/kleinanzeigen_bot/__init__.py | 14 +------------- tests/unit/test_init.py | 4 ++-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/kleinanzeigen_bot/__init__.py b/src/kleinanzeigen_bot/__init__.py index 4f60429..36d2991 100644 --- a/src/kleinanzeigen_bot/__init__.py +++ b/src/kleinanzeigen_bot/__init__.py @@ -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") diff --git a/tests/unit/test_init.py b/tests/unit/test_init.py index d8214e3..cb93875 100644 --- a/tests/unit/test_init.py +++ b/tests/unit/test_init.py @@ -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), \