From cd6a2b6031e57de98ae3b49e0a36425c7974ad82 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Wed, 11 Jun 2025 20:05:35 +0100 Subject: [PATCH] generic_extractor download tests adaptations --- tests/.env.test.example | 5 ++++- tests/extractors/test_generic_extractor.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/.env.test.example b/tests/.env.test.example index 367d3f5..1f6f45f 100644 --- a/tests/.env.test.example +++ b/tests/.env.test.example @@ -7,4 +7,7 @@ LINKEDIN_TEST_USERNAME="" LINKEDIN_TEST_PASSWORD="" # twitter test credentials -TWITTER_BEARER_TOKEN="TEST_KEY" \ No newline at end of file +TWITTER_BEARER_TOKEN="TEST_KEY" + +# some geo/VPN IPs are blocked by truth social, disable if you have issues +TEST_TRUTH_SOCIAL="true" \ No newline at end of file diff --git a/tests/extractors/test_generic_extractor.py b/tests/extractors/test_generic_extractor.py index de5470b..fe3baf5 100644 --- a/tests/extractors/test_generic_extractor.py +++ b/tests/extractors/test_generic_extractor.py @@ -10,6 +10,7 @@ from auto_archiver.modules.generic_extractor.generic_extractor import GenericExt from .test_extractor_base import TestExtractorBase CI = os.getenv("GITHUB_ACTIONS", "") == "true" +TEST_TRUTH_SOCIAL = os.getenv("TEST_TRUTH_SOCIAL", "") == "true" class TestGenericExtractor(TestExtractorBase): @@ -149,6 +150,7 @@ class TestGenericExtractor(TestExtractorBase): result = self.extractor.download(item) assert result is not False + @pytest.mark.skipif(not TEST_TRUTH_SOCIAL, reason="Truth social download tests disabled in environment variables.") @pytest.mark.skipif(CI, reason="Truth social blocks GH actions.") @pytest.mark.download def test_truthsocial_download_video(self, make_item): @@ -157,6 +159,7 @@ class TestGenericExtractor(TestExtractorBase): assert len(result.media) == 1 assert result is not False + @pytest.mark.skipif(not TEST_TRUTH_SOCIAL, reason="Truth social download tests disabled in environment variables.") @pytest.mark.skipif(CI, reason="Truth social blocks GH actions.") @pytest.mark.download def test_truthsocial_download_no_media(self, make_item): @@ -164,6 +167,7 @@ class TestGenericExtractor(TestExtractorBase): result = self.extractor.download(item) assert result is not False + @pytest.mark.skipif(not TEST_TRUTH_SOCIAL, reason="Truth social download tests disabled in environment variables.") @pytest.mark.skipif(CI, reason="Truth social blocks GH actions.") @pytest.mark.download def test_truthsocial_download_poll(self, make_item): @@ -171,6 +175,7 @@ class TestGenericExtractor(TestExtractorBase): result = self.extractor.download(item) assert result is not False + @pytest.mark.skipif(not TEST_TRUTH_SOCIAL, reason="Truth social download tests disabled in environment variables.") @pytest.mark.skipif(CI, reason="Truth social blocks GH actions.") @pytest.mark.download def test_truthsocial_download_single_image(self, make_item): @@ -179,6 +184,7 @@ class TestGenericExtractor(TestExtractorBase): assert len(result.media) == 1 assert result is not False + @pytest.mark.skipif(not TEST_TRUTH_SOCIAL, reason="Truth social download tests disabled in environment variables.") @pytest.mark.skipif(CI, reason="Truth social blocks GH actions.") @pytest.mark.download def test_truthsocial_download_multiple_images(self, make_item): @@ -276,6 +282,7 @@ class TestGenericExtractor(TestExtractorBase): assert "Bellingchat Premium is with Kolina Koltai" in post.get_title() + @pytest.mark.skip(reason="Newer yt-dlp versions don't support image download.") @pytest.mark.download def test_download_facebook_image(self, make_item): post = self.extractor.download(