fix: Make description field optional in ad_defaults

The description field in the main configuration (ad_defaults) is now optional.
Previously, the bot would fail if no description or affixes were provided in
the main configuration. This change addresses issue #435.

Changes:
- Add fallback to empty string ("") when all description prefix/suffix sources
  are None in __get_description_with_affixes method
- Add comprehensive test suite for description handling in test_init.py
- Fix coverage path in pyproject.toml from 'kleinanzeigen_bot' to
  'src/kleinanzeigen_bot'

New tests cover:
- Description handling without main config description
- New format affixes in configuration
- Mixed old/new format affixes
- Ad-level affix precedence
- None value handling in affixes
- Email address @ symbol replacement

This change maintains backward compatibility while making the description
field optional in the main configuration, improving flexibility for users.
This commit is contained in:
Jens Bergmann
2025-02-17 20:34:53 +01:00
committed by Sebastian Thomschke
parent a8f6817c5c
commit c7f7b832b2
3 changed files with 119 additions and 2 deletions

View File

@@ -1080,6 +1080,7 @@ class KleinanzeigenBot(WebScrapingMixin):
if dicts.safe_get(ad_cfg, "description", "prefix") is not None
# 3. Global prefix from config
else get_description_affixes(self.config, prefix=True)
or "" # Default to empty string if all sources are None
)
# Get suffix with precedence
@@ -1091,6 +1092,7 @@ class KleinanzeigenBot(WebScrapingMixin):
if dicts.safe_get(ad_cfg, "description", "suffix") is not None
# 3. Global suffix from config
else get_description_affixes(self.config, prefix=False)
or "" # Default to empty string if all sources are None
)
# Combine the parts and replace @ with (at)