mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
## ℹ️ Description *Provide a concise summary of the changes introduced in this pull request.* - Link to the related issue(s): Issue # - Describe the motivation and context for this change. Refactors the test harness for faster and more reliable feedback: adds deterministic time freezing for update checks, accelerates and refactors smoke tests to run in-process, defaults pytest to xdist with durations tracking, and adjusts CI triggers so PRs run the test matrix only once. ## 📋 Changes Summary - add pytest-xdist + durations reporting defaults, force deterministic locale and slow markers, and document the workflow adjustments - run smoke tests in-process (no subprocess churn), mock update checks/logging, and mark slow specs appropriately - deflake update check interval tests by freezing datetime and simplify FixedDateTime helper - limit GitHub Actions `push` trigger to `main` so feature branches rely on the single pull_request run ### ⚙️ Type of Change Select the type(s) of change(s) included in this pull request: - [ ] 🐞 Bug fix (non-breaking change which fixes an issue) - [x] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist Before requesting a review, confirm the following: - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Ensure tests run in a consistent English locale and restore prior locale after each run * Mark integration scraping tests as slow for clearer categorization * Replace subprocess-based CLI tests with an in-process runner that returns structured results and captures combined stdout/stderr/logs; disable update checks during smoke tests * Freeze current time in update-check tests for deterministic assertions * Add mock for process enumeration in web‑scraping unit tests to stabilize macOS-specific warnings <!-- end of auto-generated comment: release notes by coderabbit.ai -->
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# SPDX-ArtifactOfProjectHomePage: https://github.com/Second-Hand-Friends/kleinanzeigen-bot/
|
|
import platform
|
|
from typing import cast
|
|
|
|
import nodriver
|
|
import pytest
|
|
|
|
from kleinanzeigen_bot.utils.misc import ensure
|
|
from kleinanzeigen_bot.utils.web_scraping_mixin import WebScrapingMixin
|
|
|
|
pytestmark = pytest.mark.slow
|
|
|
|
# Configure logging for integration tests
|
|
# The main bot already handles nodriver logging via silence_nodriver_logs fixture
|
|
# and pytest handles verbosity with -v flag automatically
|
|
|
|
|
|
async def atest_init() -> None:
|
|
web_scraping_mixin = WebScrapingMixin()
|
|
if platform.system() == "Linux":
|
|
# required for Ubuntu 24.04 or newer
|
|
cast(list[str], web_scraping_mixin.browser_config.arguments).append("--no-sandbox")
|
|
|
|
browser_path = web_scraping_mixin.get_compatible_browser()
|
|
ensure(browser_path is not None, "Browser not auto-detected")
|
|
|
|
web_scraping_mixin.close_browser_session()
|
|
try:
|
|
await web_scraping_mixin.create_browser_session()
|
|
finally:
|
|
web_scraping_mixin.close_browser_session()
|
|
|
|
|
|
@pytest.mark.flaky(reruns = 4, reruns_delay = 5)
|
|
@pytest.mark.itest
|
|
def test_init() -> None:
|
|
nodriver.loop().run_until_complete(atest_init()) # type: ignore[attr-defined]
|