Fix instagram_extractor.py typo, add warning to docs, and add basic regex test.

This commit is contained in:
erinhmclark
2025-03-06 16:25:38 +00:00
parent a705a78632
commit fa1e65f54c
3 changed files with 27 additions and 26 deletions

View File

@@ -1,11 +1,10 @@
import pytest
from auto_archiver.modules.instagram_extractor import InstagramExtractor
from .test_extractor_base import TestExtractorBase
@pytest.fixture
def intsagram_extractor(setup_module):
def instagram_extractor(setup_module, mocker):
extractor_module: str = 'instagram_extractor'
config: dict = {
@@ -14,11 +13,14 @@ def intsagram_extractor(setup_module):
"download_folder": "instaloader",
"session_file": "secrets/instaloader.session",
}
fake_loader = mocker.MagicMock()
fake_loader.load_session_from_file.return_value = None
fake_loader.login.return_value = None
fake_loader.save_session_to_file.return_value = None
mocker.patch("instaloader.Instaloader", return_value=fake_loader,)
return setup_module(extractor_module, config)
@pytest.mark.parametrize("url", [
"https://www.instagram.com/p/",
"https://www.instagram.com/p/1234567890/",
@@ -27,6 +29,8 @@ def intsagram_extractor(setup_module):
"https://www.instagram.com/username/stories/",
"https://www.instagram.com/username/highlights/",
])
def test_regex_matches(url, instagram_extractor):
# post
assert instagram_extractor.valid_url.match(url)
def test_regex_matches(url: str, instagram_extractor: InstagramExtractor) -> None:
"""
Ensure that the valid_url regex matches all provided Instagram URLs.
"""
assert instagram_extractor.valid_url.match(url)