1
0
Fork 0
mirror of synced 2024-06-08 21:34:37 +12:00

Merge branch 'aliparlakci:development' into DelayForReddit

This commit is contained in:
OMEGA_RAZER 2022-11-11 17:38:16 -05:00 committed by GitHub
commit 0a586425d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 18 deletions

View file

@ -114,7 +114,10 @@ class RedditDownloader(RedditConnector):
f'Resource hash {resource_hash} from submission {submission.id} downloaded elsewhere')
return
elif self.args.make_hard_links:
self.master_hash_list[resource_hash].link_to(destination)
try:
destination.hardlink_to(self.master_hash_list[resource_hash])
except AttributeError:
self.master_hash_list[resource_hash].link_to(destination)
logger.info(
f'Hard link made linking {destination} to {self.master_hash_list[resource_hash]}'
f' in submission {submission.id}')

View file

@ -13,10 +13,9 @@ from bdfr.site_downloaders.pornhub import PornHub
@pytest.mark.online
@pytest.mark.slow
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
('https://www.pornhub.com/view_video.php?viewkey=ph6074c59798497', 'd9b99e4ebecf2d8d67efe5e70d2acf8a'),
('https://www.pornhub.com/view_video.php?viewkey=ph5ede121f0d3f8', ''),
('https://www.pornhub.com/view_video.php?viewkey=ph6074c59798497', 'ad52a0f4fce8f99df0abed17de1d04c7'),
))
def test_find_resources_good(test_url: str, expected_hash: str):
def test_hash_resources_good(test_url: str, expected_hash: str):
test_submission = MagicMock()
test_submission.url = test_url
downloader = PornHub(test_submission)

View file

@ -51,7 +51,7 @@ def do_test_path_equality(result: Path, expected: str) -> bool:
@pytest.fixture(scope='session')
def reddit_submission(reddit_instance: praw.Reddit) -> praw.models.Submission:
return reddit_instance.submission(id='lgilgt')
return reddit_instance.submission(id='w22m5l')
@pytest.mark.parametrize(('test_format_string', 'expected'), (
@ -86,12 +86,12 @@ def test_check_format_string_validity(test_string: str, expected: bool):
@pytest.mark.online
@pytest.mark.reddit
@pytest.mark.parametrize(('test_format_string', 'expected'), (
('{SUBREDDIT}', 'Mindustry'),
('{REDDITOR}', 'Gamer_player_boi'),
('{POSTID}', 'lgilgt'),
('{FLAIR}', 'Art'),
('{SUBREDDIT}_{TITLE}', 'Mindustry_Toxopid that is NOT humane >:('),
('{REDDITOR}_{TITLE}_{POSTID}', 'Gamer_player_boi_Toxopid that is NOT humane >:(_lgilgt')
('{SUBREDDIT}', 'formula1'),
('{REDDITOR}', 'Kirsty-Blue'),
('{POSTID}', 'w22m5l'),
('{FLAIR}', 'Social Media rall'),
('{SUBREDDIT}_{TITLE}', 'formula1_George Russel acknowledges the Twitter trend about him'),
('{REDDITOR}_{TITLE}_{POSTID}', 'Kirsty-Blue_George Russel acknowledges the Twitter trend about him_w22m5l')
))
def test_format_name_real(test_format_string: str, expected: str, reddit_submission: praw.models.Submission):
test_formatter = FileNameFormatter(test_format_string, '', '')
@ -105,17 +105,17 @@ def test_format_name_real(test_format_string: str, expected: str, reddit_submiss
(
'{SUBREDDIT}',
'{POSTID}',
'test/Mindustry/lgilgt.png',
'test/formula1/w22m5l.png',
),
(
'{SUBREDDIT}',
'{TITLE}_{POSTID}',
'test/Mindustry/Toxopid that is NOT humane >:(_lgilgt.png',
'test/formula1/George Russel acknowledges the Twitter trend about him_w22m5l.png',
),
(
'{SUBREDDIT}',
'{REDDITOR}_{TITLE}_{POSTID}',
'test/Mindustry/Gamer_player_boi_Toxopid that is NOT humane >:(_lgilgt.png',
'test/formula1/Kirsty-Blue_George Russel acknowledges the Twitter trend about him_w22m5l.png',
),
))
def test_format_full(
@ -148,10 +148,10 @@ def test_format_full_conform(
@pytest.mark.online
@pytest.mark.reddit
@pytest.mark.parametrize(('format_string_directory', 'format_string_file', 'index', 'expected'), (
('{SUBREDDIT}', '{POSTID}', None, 'test/Mindustry/lgilgt.png'),
('{SUBREDDIT}', '{POSTID}', 1, 'test/Mindustry/lgilgt_1.png'),
('{SUBREDDIT}', '{POSTID}', 2, 'test/Mindustry/lgilgt_2.png'),
('{SUBREDDIT}', '{TITLE}_{POSTID}', 2, 'test/Mindustry/Toxopid that is NOT humane >:(_lgilgt_2.png'),
('{SUBREDDIT}', '{POSTID}', None, 'test/formula1/w22m5l.png'),
('{SUBREDDIT}', '{POSTID}', 1, 'test/formula1/w22m5l_1.png'),
('{SUBREDDIT}', '{POSTID}', 2, 'test/formula1/w22m5l_2.png'),
('{SUBREDDIT}', '{TITLE}_{POSTID}', 2, 'test/formula1/George Russel acknowledges the Twitter trend about him_w22m5l_2.png'),
))
def test_format_full_with_index_suffix(
format_string_directory: str,