Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Dec 6, 2024
1 parent bc18cd0 commit 34b596f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions scraper/tests-integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import tempfile
import threading
from collections.abc import Generator
from pathlib import Path
from typing import Any

import pytest
from zimscraperlib.download import get_session

from mindtouch2zim.context import Context

CONTEXT_DEFAULTS = {
"web_session": get_session(),
"tmp_folder": None,
"cache_folder": None,
"_current_thread_workitem": threading.local(),
"library_url": None,
"creator": None,
"name": None,
"title": None,
"description": None,
}


# initialize a context since it is a requirement for most modules to load
Context.setup(**CONTEXT_DEFAULTS)


@pytest.fixture(scope="module")
Expand Down
8 changes: 5 additions & 3 deletions scraper/tests-integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
MindtouchClient,
MindtouchHome,
)
from mindtouch2zim.context import CONTEXT
from mindtouch2zim.context import Context
from mindtouch2zim.download import stream_file

context = Context.get()


@pytest.fixture(scope="module")
def client(libretexts_url: str, cache_folder: Path) -> MindtouchClient:
CONTEXT.library_url = libretexts_url
CONTEXT.cache_folder = cache_folder
context.library_url = libretexts_url
context.cache_folder = cache_folder
return MindtouchClient()


Expand Down

0 comments on commit 34b596f

Please sign in to comment.