-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import pytest | ||
|
||
from src.instagram import InstagramDownloader | ||
from Tests.video_system.regex.test_regex_base import TestDownloaderRegex | ||
|
||
|
||
class TestInstagramRegex(TestDownloaderRegex): | ||
@pytest.fixture(autouse=True) | ||
def setup_class(self): | ||
super().setup(InstagramDownloader) | ||
|
||
def test_direct_reel_link(self): | ||
assert self.check_link("https://www.instagram.com/reel/C2-vIqjsosW") | ||
|
||
def test_direct_post_link(self): | ||
assert self.check_link("https://www.instagram.com/p/C2-vIqjsosW") | ||
|
||
def test_direct_link_with_params(self): | ||
assert self.check_link( | ||
"https://www.instagram.com/p/C2-vIqjsosW/?igsh=eGFma20zbWY0bDJs" | ||
) | ||
assert self.check_link( | ||
"https://www.instagram.com/reel/C2-vIqjsosW/?igsh=eGFma20zbWY0bDJs" | ||
) | ||
|
||
def test_shortened_link(self): | ||
assert self.check_link("https://instagr.am/p/C2-vIqjsosW") | ||
assert self.check_link("https://instagr.am/reel/C2-vIqjsosW") | ||
|
||
def test_extra_text_link(self): | ||
assert self.check_link( | ||
"Check this out: https://www.instagram.com/p/C2-vIqjsosW" | ||
) | ||
assert self.check_link( | ||
"Check this out: https://www.instagram.com/reel/C2-vIqjsosW" | ||
) | ||
assert self.check_link( | ||
"Dude look at this video fr fr https://www.instagram.com/reel/C2-vIqjsosW" | ||
) | ||
|
||
def test_invalid_link(self): | ||
assert not self.check_link("https://www.instagram.com") | ||
|
||
def test_invalid_link_with_extra(self): | ||
assert not self.check_link("Look at this: https://www.instagram.com") | ||
|
||
def test_invalid_shortened_link(self): | ||
assert not self.check_link("https://instagr.am") | ||
|
||
def test_different_type_links(self): | ||
assert not self.check_link("https://www.youtube.com/watch?v=dQw4w9WgXcQ") | ||
assert not self.check_link("https://x.com/MIT_CSAIL/status/1363172815315214336") | ||
|
||
def test_non_link(self): | ||
assert not self.check_link("This is not a link") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from src.downloading_system import get_downloader | ||
|
||
|
||
class TestOtherDownloaderRegex: | ||
def check_link(self, link: str): | ||
return get_downloader(link) is not None | ||
|
||
def test_not_supported_links(self): | ||
assert not self.check_link("https://facebook.com/1234") | ||
assert not self.check_link( | ||
"https://www.linkedin.com/posts/microsoft_microsoftlife-microsoftcareersemea-softwareengineerjobs-activity-7231661283509460992-3NLl" | ||
) | ||
assert not self.check_link("https://twitch.tv/1234") | ||
|
||
def test_link_like_non_links(self): | ||
assert not self.check_link("This is not a link") | ||
assert not self.check_link("alink://link/link") | ||
assert not self.check_link("https://") | ||
assert not self.check_link("https://youtube./com/123") | ||
assert not self.check_link("https://x./com/123") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Type | ||
|
||
from src.downloader import VideoDownloader | ||
from src.downloading_system import get_downloader | ||
|
||
|
||
class TestDownloaderRegex: | ||
def setup(self, downloader_type_to_check: Type[VideoDownloader]) -> None: | ||
self.downloader_type = downloader_type_to_check | ||
|
||
def check_link(self, link: str): | ||
downloader = get_downloader(link) | ||
return downloader is not None and isinstance(downloader(), self.downloader_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
from src.Youtube import YoutubeDownloader | ||
from Tests.video_system.regex.test_regex_base import TestDownloaderRegex | ||
|
||
|
||
class TestYoutubeRegex(TestDownloaderRegex): | ||
@pytest.fixture(autouse=True) | ||
def setup_class(self): | ||
super().setup(YoutubeDownloader) | ||
|
||
def test_direct_link(self): | ||
assert self.check_link("https://www.youtube.com/watch?v=dQw4w9WgXcQ") | ||
|
||
def test_direct_link_with_timestamp(self): | ||
assert self.check_link("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=10s") | ||
|
||
def test_shortened_link(self): | ||
assert self.check_link("https://youtu.be/dQw4w9WgXcQ") | ||
|
||
def test_shortened_link_with_timestamp(self): | ||
assert self.check_link("https://youtu.be/dQw4w9WgXcQ?t=10") | ||
|
||
def test_share_parameter_link(self): | ||
assert self.check_link("https://youtu.be/dQw4w9WgXcQ?si=T3vbuTjMmskB3x3d") | ||
|
||
def test_extra_text_link(self): | ||
assert self.check_link( | ||
"Check this out: https://www.youtube.com/watch?v=dQw4w9WgXcQ" | ||
) | ||
|
||
def test_invalid_link(self): | ||
assert not self.check_link("https://www.youtube.com") | ||
|
||
def test_invalid_shortened_link(self): | ||
assert not self.check_link("https://youtu.be") | ||
|
||
def test_different_type_links(self): | ||
assert not self.check_link("https://www.instagram.com/p/CMJ1J1JjJjJ/") | ||
assert not self.check_link("https://x.com/MIT_CSAIL/status/1363172815315214336") |