Add integration test for downloading user contents
This commit is contained in:
parent
932b42eafc
commit
917c3fc7a7
@ -65,4 +65,11 @@ test $(sqlite3 data/twitter.db "select count(*) from tweets") = "2"
|
|||||||
test $(sqlite3 data/twitter.db "select count(*) from videos") = "1"
|
test $(sqlite3 data/twitter.db "select count(*) from videos") = "1"
|
||||||
|
|
||||||
|
|
||||||
|
# Download a user's profile image and banner image
|
||||||
|
test $(sqlite3 data/twitter.db "select is_content_downloaded from users where handle = 'DiamondChariots'") = "0"
|
||||||
|
./tw download_user_content data DiamondChariots
|
||||||
|
test $(sqlite3 data/twitter.db "select is_content_downloaded from users where handle = 'DiamondChariots'") = "1"
|
||||||
|
test -f data/profile_images/DiamondChariots_profile_rE4OTedS.jpg
|
||||||
|
test -f data/profile_images/DiamondChariots_banner_1615811094.jpg
|
||||||
|
|
||||||
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"
|
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"
|
||||||
|
@ -53,6 +53,8 @@ func main() {
|
|||||||
fetch_tweet_only(target)
|
fetch_tweet_only(target)
|
||||||
case "download_tweet_content":
|
case "download_tweet_content":
|
||||||
download_tweet_content(target)
|
download_tweet_content(target)
|
||||||
|
case "download_user_content":
|
||||||
|
download_user_content(scraper.UserHandle(target))
|
||||||
default:
|
default:
|
||||||
die("Invalid operation: " + operation, true, 3)
|
die("Invalid operation: " + operation, true, 3)
|
||||||
}
|
}
|
||||||
@ -137,3 +139,14 @@ func download_tweet_content(tweet_id string) {
|
|||||||
panic("Error getting content: " + err.Error())
|
panic("Error getting content: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func download_user_content(handle scraper.UserHandle) {
|
||||||
|
user, err := profile.GetUserByHandle(handle)
|
||||||
|
if err != nil {
|
||||||
|
panic("Couldn't get the user from database: " + err.Error())
|
||||||
|
}
|
||||||
|
err = profile.DownloadUserContentFor(&user)
|
||||||
|
if err != nil {
|
||||||
|
panic("Error getting content: " + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user