diff --git a/scripts/tests/example_logfiles/failed_disabled_module.txt b/scripts/tests/example_logfiles/failed_disabled_module.txt new file mode 100644 index 0000000..50fd552 --- /dev/null +++ b/scripts/tests/example_logfiles/failed_disabled_module.txt @@ -0,0 +1 @@ +[2021-06-12 12:49:18,452 - bdfr.downloader - DEBUG] - Submission m2601g skipped due to disabled module Direct diff --git a/scripts/tests/example_logfiles/failed_no_downloader.txt b/scripts/tests/example_logfiles/failed_no_downloader.txt new file mode 100644 index 0000000..511d11f --- /dev/null +++ b/scripts/tests/example_logfiles/failed_no_downloader.txt @@ -0,0 +1,3 @@ +[2021-06-12 11:13:35,665 - bdfr.downloader - ERROR] - Could not download submission nxv3ew: No downloader module exists for url https://www.biorxiv.org/content/10.1101/2021.06.11.447961v1?rss=1 +[2021-06-12 11:14:21,958 - bdfr.downloader - ERROR] - Could not download submission nxv3ek: No downloader module exists for url https://alkossegyedit.hu/termek/pluss-macko-poloval-20cm/?feed_id=34832&_unique_id=60c40a1190ccb&utm_source=Reddit&utm_medium=AEAdmin&utm_campaign=Poster +[2021-06-12 11:17:53,456 - bdfr.downloader - ERROR] - Could not download submission nxv3ea: No downloader module exists for url https://www.biorxiv.org/content/10.1101/2021.06.11.448067v1?rss=1 diff --git a/scripts/tests/example_logfiles/failed_resource_error.txt b/scripts/tests/example_logfiles/failed_resource_error.txt new file mode 100644 index 0000000..c2ba24c --- /dev/null +++ b/scripts/tests/example_logfiles/failed_resource_error.txt @@ -0,0 +1,2 @@ +[2021-06-12 11:18:25,794 - bdfr.downloader - ERROR] - Failed to download resource https://i.redd.it/61fniokpjq471.jpg in submission nxv3dt with downloader Direct: Unrecoverable error requesting resource: HTTP Code 404 + diff --git a/scripts/tests/example_logfiles/failed_sitedownloader_error.txt b/scripts/tests/example_logfiles/failed_sitedownloader_error.txt new file mode 100644 index 0000000..379ddac --- /dev/null +++ b/scripts/tests/example_logfiles/failed_sitedownloader_error.txt @@ -0,0 +1,2 @@ +[2021-06-12 08:38:35,657 - bdfr.downloader - ERROR] - Site Gallery failed to download submission nxr7x9: No images found in Reddit gallery +[2021-06-12 08:47:22,005 - bdfr.downloader - ERROR] - Site Gallery failed to download submission nxpn0h: Server responded with 503 to https://www.reddit.com/gallery/nxpkvh diff --git a/scripts/tests/example_logfiles/failed_write_error.txt b/scripts/tests/example_logfiles/failed_write_error.txt new file mode 100644 index 0000000..2462366 --- /dev/null +++ b/scripts/tests/example_logfiles/failed_write_error.txt @@ -0,0 +1 @@ +[2021-06-09 22:01:04,530 - bdfr.downloader - ERROR] - Failed to write file in submission nnboza to C:\Users\Yoga 14\path\to\output\ThotNetwork\KatieCarmine_I POST A NEW VIDEO ALMOST EVERYDAY AND YOU NEVER HAVE TO PAY EXTRA FOR IT! I want to share my sex life with you! Only $6 per month and you get full access to over 400 videos of me getting fuck_nnboza.mp4: [Errno 2] No such file or directory: 'C:\\Users\\Yoga 14\\path\\to\\output\\ThotNetwork\\KatieCarmine_I POST A NEW VIDEO ALMOST EVERYDAY AND YOU NEVER HAVE TO PAY EXTRA FOR IT! I want to share my sex life with you! Only $6 per month and you get full access to over 400 videos of me getting fuck_nnboza.mp4' diff --git a/scripts/tests/example_logfiles/succeed_already_exists.txt b/scripts/tests/example_logfiles/succeed_already_exists.txt new file mode 100644 index 0000000..e5713d7 --- /dev/null +++ b/scripts/tests/example_logfiles/succeed_already_exists.txt @@ -0,0 +1,3 @@ +[2021-06-12 08:41:51,464 - bdfr.downloader - DEBUG] - File /media/smaug/private/reddit/tumblr/nxry0l.jpg from submission nxry0l already exists, continuing +[2021-06-12 08:41:51,469 - bdfr.downloader - DEBUG] - File /media/smaug/private/reddit/tumblr/nxrlgn.gif from submission nxrlgn already exists, continuing +[2021-06-12 08:41:51,472 - bdfr.downloader - DEBUG] - File /media/smaug/private/reddit/tumblr/nxrq9g.png from submission nxrq9g already exists, continuing diff --git a/scripts/tests/example_logfiles/succeed_download_filter.txt b/scripts/tests/example_logfiles/succeed_download_filter.txt new file mode 100644 index 0000000..ce4c41d --- /dev/null +++ b/scripts/tests/example_logfiles/succeed_download_filter.txt @@ -0,0 +1,3 @@ +[2021-06-10 20:36:48,722 - bdfr.downloader - DEBUG] - Download filter removed nwfirr with URL https://www.youtube.com/watch?v=NVSiX0Tsees +[2021-06-12 19:56:36,848 - bdfr.downloader - DEBUG] - Download filter removed nwfgcl with URL https://www.reddit.com/r/MaliciousCompliance/comments/nwfgcl/new_guy_decided_to_play_manager_alright/ +[2021-06-12 19:56:28,587 - bdfr.downloader - DEBUG] - Download filter removed nxuxjy with URL https://www.reddit.com/r/MaliciousCompliance/comments/nxuxjy/you_want_an_omelette_with_nothing_inside_okay/ diff --git a/scripts/tests/example_logfiles/succeed_downloaded_submission.txt b/scripts/tests/example_logfiles/succeed_downloaded_submission.txt new file mode 100644 index 0000000..fde97fa --- /dev/null +++ b/scripts/tests/example_logfiles/succeed_downloaded_submission.txt @@ -0,0 +1,7 @@ +[2021-06-12 11:58:53,864 - bdfr.downloader - INFO] - Downloaded submission nxui9y from tumblr +[2021-06-12 11:58:56,618 - bdfr.downloader - INFO] - Downloaded submission nxsr4r from tumblr +[2021-06-12 11:58:59,026 - bdfr.downloader - INFO] - Downloaded submission nxviir from tumblr +[2021-06-12 11:59:00,289 - bdfr.downloader - INFO] - Downloaded submission nxusva from tumblr +[2021-06-12 11:59:00,735 - bdfr.downloader - INFO] - Downloaded submission nxvko7 from tumblr +[2021-06-12 11:59:01,215 - bdfr.downloader - INFO] - Downloaded submission nxvd63 from tumblr +[2021-06-12 11:59:13,891 - bdfr.downloader - INFO] - Downloaded submission nn9cor from tumblr diff --git a/scripts/tests/example_logfiles/succeed_hard_link.txt b/scripts/tests/example_logfiles/succeed_hard_link.txt new file mode 100644 index 0000000..6359f6b --- /dev/null +++ b/scripts/tests/example_logfiles/succeed_hard_link.txt @@ -0,0 +1 @@ +[2021-06-11 17:33:02,118 - bdfr.downloader - INFO] - Hard link made linking /media/smaug/private/reddit/tumblr/nwnp2n.jpg to /media/smaug/private/reddit/tumblr/nwskqb.jpg in submission nwnp2n diff --git a/scripts/tests/example_logfiles/succeed_resource_hash.txt b/scripts/tests/example_logfiles/succeed_resource_hash.txt new file mode 100644 index 0000000..a089750 --- /dev/null +++ b/scripts/tests/example_logfiles/succeed_resource_hash.txt @@ -0,0 +1 @@ +[2021-06-11 17:33:02,118 - bdfr.downloader - INFO] - Resource hash aaaaaaaaaaaaaaaaaaaaaaa from submission n86jk8 downloaded elsewhere diff --git a/scripts/tests/test_extract_failed_ids.bats b/scripts/tests/test_extract_failed_ids.bats index e69de29..75b9bff 100644 --- a/scripts/tests/test_extract_failed_ids.bats +++ b/scripts/tests/test_extract_failed_ids.bats @@ -0,0 +1,43 @@ +setup() { + load ./test_helper/bats-support/load + load ./test_helper/bats-assert/load +} + +teardown() { + rm -f failed.txt +} + +@test "fail run no logfile" { + run ../extract_failed_ids.sh + assert_failure +} + +@test "fail no downloader module" { + run ../extract_failed_ids.sh ./example_logfiles/failed_no_downloader.txt + assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "3" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ]; +} + +@test "fail resource error" { + run ../extract_failed_ids.sh ./example_logfiles/failed_resource_error.txt + assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ]; +} + +@test "fail site downloader error" { + run ../extract_failed_ids.sh ./example_logfiles/failed_sitedownloader_error.txt + assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "2" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ]; +} + +@test "fail failed file write" { + run ../extract_failed_ids.sh ./example_logfiles/failed_write_error.txt + assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ]; +} + +@test "fail disabled module" { + run ../extract_failed_ids.sh ./example_logfiles/failed_disabled_module.txt + assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ]; +} diff --git a/scripts/tests/test_extract_successful_ids.bats b/scripts/tests/test_extract_successful_ids.bats index e69de29..364bedb 100644 --- a/scripts/tests/test_extract_successful_ids.bats +++ b/scripts/tests/test_extract_successful_ids.bats @@ -0,0 +1,38 @@ +setup() { + load ./test_helper/bats-support/load + load ./test_helper/bats-assert/load +} + +teardown() { + rm -f successful.txt +} + +@test "success downloaded submission" { + run ../extract_successful_ids.sh ./example_logfiles/succeed_downloaded_submission.txt + assert [ "$( wc -l 'successful.txt' | awk '{ print $1 }' )" -eq "7" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'successful.txt' )" -eq "0" ]; +} + +@test "success resource hash" { + run ../extract_successful_ids.sh ./example_logfiles/succeed_resource_hash.txt + assert [ "$( wc -l 'successful.txt' | awk '{ print $1 }' )" -eq "1" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'successful.txt' )" -eq "0" ]; +} + +@test "success download filter" { + run ../extract_successful_ids.sh ./example_logfiles/succeed_download_filter.txt + assert [ "$( wc -l 'successful.txt' | awk '{ print $1 }' )" -eq "3" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'successful.txt' )" -eq "0" ]; +} + +@test "success already exists" { + run ../extract_successful_ids.sh ./example_logfiles/succeed_already_exists.txt + assert [ "$( wc -l 'successful.txt' | awk '{ print $1 }' )" -eq "3" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'successful.txt' )" -eq "0" ]; +} + +@test "success hard link" { + run ../extract_successful_ids.sh ./example_logfiles/succeed_hard_link.txt + assert [ "$( wc -l 'successful.txt' | awk '{ print $1 }' )" -eq "1" ]; + assert [ "$( grep -Ecv '\w{6,7}' 'successful.txt' )" -eq "0" ]; +}