Skip to content

Commit

Permalink
Fix video outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
cguess committed Dec 19, 2023
1 parent 2fed58a commit cc848fb
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 158 deletions.
212 changes: 106 additions & 106 deletions test/tweet_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,63 @@ def teardown
cleanup_temp_folder
end

# def test_that_a_tweet_is_created_with_id
# tweets = Mosquito::Tweet.lookup("1378268627615543296")
# assert_not_nil tweets
# assert_equal 1, tweets.count
# tweets.each { |tweet| assert_instance_of Mosquito::Tweet, tweet }
# end

# def test_that_a_tweet_with_a_nil_author_url_is_recreated
# tweets = Mosquito::Tweet.lookup("1735069264145473926")

# # This tweet's author url should not be nil anymore
# tweets.each { |tweet| assert_instance_of Mosquito::Tweet, tweet }
# tweets.each { |tweet| assert_not_nil tweet.author.url }
# end

# def test_that_a_tweet_raises_exception_with_invalid_id
# assert_raises Mosquito::InvalidIdError do
# Mosquito::Tweet.lookup("abcdef")
# end
# end

# def test_that_a_tweet_has_correct_attributes
# tweet = Mosquito::Tweet.lookup("1378268627615543296").first
# assert_equal "1378268627615543296", tweet.id
# assert_equal DateTime.parse("2021-04-03T08:50:00.000Z"), tweet.created_at
# assert_equal "Five years ago... #PanamaPapers #OnThisDay @ICIJorg @SZ panamapapers.sueddeutsche.de…", tweet.text
# assert_equal "en", tweet.language
# assert_equal "Frederik Obermaier", tweet.author.name
# end

# def test_that_a_tweet_cant_be_found_works
# assert_raises Mosquito::NoTweetFoundError do
# Mosquito::Tweet.lookup("19")
# end
# end

# def test_that_a_tweet_can_have_no_media
# tweet = Mosquito::Tweet.lookup("20").first
# assert_equal "20", tweet.id
# assert_not_nil tweet.image_file_names
# assert_equal 0, tweet.image_file_names.count
# assert_equal 0, tweet.video_file_names.count
# end

# def test_that_a_tweet_can_have_a_single_image
# tweet = Mosquito::Tweet.lookup("1407341650737762304").first
# assert_not_nil tweet.image_file_names
# assert_equal 1, tweet.image_file_names.count
# assert_equal 0, tweet.video_file_names.count
# end

# def test_that_a_tweet_can_have_a_slideshow
# tweet = Mosquito::Tweet.lookup("1407322444399099904").first
# assert_not_nil tweet.image_file_names
# assert_equal 4, tweet.image_file_names.count
# assert_equal 0, tweet.video_file_names.count
# end
def test_that_a_tweet_is_created_with_id
tweets = Mosquito::Tweet.lookup("1378268627615543296")
assert_not_nil tweets
assert_equal 1, tweets.count
tweets.each { |tweet| assert_instance_of Mosquito::Tweet, tweet }
end

def test_that_a_tweet_with_a_nil_author_url_is_recreated
tweets = Mosquito::Tweet.lookup("1735069264145473926")

# This tweet's author url should not be nil anymore
tweets.each { |tweet| assert_instance_of Mosquito::Tweet, tweet }
tweets.each { |tweet| assert_not_nil tweet.author.url }
end

def test_that_a_tweet_raises_exception_with_invalid_id
assert_raises Mosquito::InvalidIdError do
Mosquito::Tweet.lookup("abcdef")
end
end

def test_that_a_tweet_has_correct_attributes
tweet = Mosquito::Tweet.lookup("1378268627615543296").first
assert_equal "1378268627615543296", tweet.id
assert_equal DateTime.parse("2021-04-03T08:50:00.000Z"), tweet.created_at
assert_equal "Five years ago... #PanamaPapers #OnThisDay @ICIJorg @SZ panamapapers.sueddeutsche.de…", tweet.text
assert_equal "en", tweet.language
assert_equal "Frederik Obermaier", tweet.author.name
end

def test_that_a_tweet_cant_be_found_works
assert_raises Mosquito::NoTweetFoundError do
Mosquito::Tweet.lookup("19")
end
end

def test_that_a_tweet_can_have_no_media
tweet = Mosquito::Tweet.lookup("20").first
assert_equal "20", tweet.id
assert_not_nil tweet.image_file_names
assert_equal 0, tweet.image_file_names.count
assert_equal 0, tweet.video_file_names.count
end

def test_that_a_tweet_can_have_a_single_image
tweet = Mosquito::Tweet.lookup("1407341650737762304").first
assert_not_nil tweet.image_file_names
assert_equal 1, tweet.image_file_names.count
assert_equal 0, tweet.video_file_names.count
end

def test_that_a_tweet_can_have_a_slideshow
tweet = Mosquito::Tweet.lookup("1407322444399099904").first
assert_not_nil tweet.image_file_names
assert_equal 4, tweet.image_file_names.count
assert_equal 0, tweet.video_file_names.count
end

def test_that_a_tweet_can_have_a_video
tweet = Mosquito::Tweet.lookup("1734886556324728917").first
Expand All @@ -80,53 +80,53 @@ def test_that_a_tweet_can_have_a_video
assert_equal "video", tweet.video_file_type
end

# def test_that_a_tweet_can_have_a_video_preview
# tweet = Mosquito::Tweet.lookup("1734886556324728917").first
# assert_not_nil tweet.video_preview_image
# end

# def test_that_a_tweet_handles_no_variants_for_video
# tweet = Mosquito::Tweet.lookup("1258817692448051200").first
# assert_not_nil tweet.video_file_names
# assert_equal 1, tweet.video_file_names.count
# assert_equal 0, tweet.image_file_names.count
# end

# def test_that_a_tweet_can_have_a_gif
# tweet = Mosquito::Tweet.lookup("1472873480249131012").first
# assert_not_nil tweet.video_file_names
# assert_equal 0, tweet.image_file_names.count
# assert_equal 1, tweet.video_file_names.count
# end

# def test_that_a_tweet_can_have_a_gif_preview
# tweet = Mosquito::Tweet.lookup("1472873480249131012").first
# assert_not_nil tweet.video_preview_image
# end

# def test_that_user_aliases_author
# tweet = Mosquito::Tweet.lookup("1472873480249131012").first
# assert_equal tweet.author, tweet.user
# end

# def test_that_a_tweet_with_a_suspended_author_fails
# assert_raises Mosquito::NoTweetFoundError do
# Mosquito::Tweet.lookup("1329846849210114052").first
# end
# end

# def test_another_url
# Mosquito::Tweet.lookup("1673383038552768512")
# end

# def test_utf_post
# tweet = Mosquito::Tweet.lookup("1664966807789387778").first
# assert tweet.text.include? "पहली बार खुलकर बोली भारत की महामहिम राष्ट्रपति द्रोपदी"
# end

# def test_detection_of_removed_post
# assert_raises Mosquito::NoTweetFoundError do
# Mosquito::Tweet.lookup("1273770669214490626").first
# end
# end
def test_that_a_tweet_can_have_a_video_preview
tweet = Mosquito::Tweet.lookup("1734886556324728917").first
assert_not_nil tweet.video_preview_image
end

def test_that_a_tweet_handles_no_variants_for_video
tweet = Mosquito::Tweet.lookup("1258817692448051200").first
assert_not_nil tweet.video_file_names
assert_equal 1, tweet.video_file_names.count
assert_equal 0, tweet.image_file_names.count
end

def test_that_a_tweet_can_have_a_gif
tweet = Mosquito::Tweet.lookup("1472873480249131012").first
assert_not_nil tweet.video_file_names
assert_equal 0, tweet.image_file_names.count
assert_equal 1, tweet.video_file_names.count
end

def test_that_a_tweet_can_have_a_gif_preview
tweet = Mosquito::Tweet.lookup("1472873480249131012").first
assert_not_nil tweet.video_preview_image
end

def test_that_user_aliases_author
tweet = Mosquito::Tweet.lookup("1472873480249131012").first
assert_equal tweet.author, tweet.user
end

def test_that_a_tweet_with_a_suspended_author_fails
assert_raises Mosquito::NoTweetFoundError do
Mosquito::Tweet.lookup("1329846849210114052").first
end
end

def test_another_url
Mosquito::Tweet.lookup("1673383038552768512")
end

def test_utf_post
tweet = Mosquito::Tweet.lookup("1664966807789387778").first
assert tweet.text.include? "पहली बार खुलकर बोली भारत की महामहिम राष्ट्रपति द्रोपदी"
end

def test_detection_of_removed_post
assert_raises Mosquito::NoTweetFoundError do
Mosquito::Tweet.lookup("1273770669214490626").first
end
end
end
104 changes: 52 additions & 52 deletions test/user_test.rb
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
# # frozen_string_literal: true

# require "test_helper"
# require "date"

# class UserTest < Minitest::Test
# def teardown
# cleanup_temp_folder
# end

# def test_that_a_user_is_created_with_id
# tweets = Mosquito::User.lookup("f_obermaier")
# tweets.each { |user| assert_instance_of Mosquito::User, user }
# end

# # This could break if Frederik ever changes his info. That's probably the reason if this is failing
# def test_that_a_user_has_correct_attributes
# user = Mosquito::User.lookup("f_obermaier").first
# assert_equal "f_obermaier", user.id
# assert_equal DateTime.parse("2011-11-04T07:18:00.000Z"), user.created_at
# assert_equal "https://nitter.ktachibana.party/pic/pbs.twimg.com%2Fprofile_images%2F1140973306889277440%2Fq3P0CIh6.jpg", user.profile_image_url
# assert_equal "Frederik Obermaier", user.name
# assert_equal "f_obermaier", user.username
# assert_equal "Threema FPN4FKZE | PGP", user.location
# assert user.description.include? "journalist"
# assert_not_nil user.url
# assert_kind_of Integer, user.followers_count
# assert_kind_of Integer, user.following_count
# assert_kind_of Integer, user.tweet_count
# assert_kind_of Integer, user.listed_count
# assert user.verified == false
# assert user.profile_image_file_name.empty? == false

# # Make sure the file is created properly
# assert File.exist?(user.profile_image_file_name) && File.file?(user.profile_image_file_name)
# end

# def test_that_a_user_has_a_url
# user = Mosquito::User.lookup("scrippsnews").first
# assert_equal "https://www.scrippsnews.com/where-to-watch/", user.url
# end

# def test_that_a_verified_user_is_probably_marked
# user = Mosquito::User.lookup("jack").first
# assert user.verified
# end

# def test_that_a_user_name_is_utf
# user = Mosquito::User.lookup("YadavArunesh").first
# assert user.name.include? "डॉ अरुणेश यादव"
# end
# end
# frozen_string_literal: true

require "test_helper"
require "date"

class UserTest < Minitest::Test
def teardown
cleanup_temp_folder
end

def test_that_a_user_is_created_with_id
tweets = Mosquito::User.lookup("f_obermaier")
tweets.each { |user| assert_instance_of Mosquito::User, user }
end

# This could break if Frederik ever changes his info. That's probably the reason if this is failing
def test_that_a_user_has_correct_attributes
user = Mosquito::User.lookup("f_obermaier").first
assert_equal "f_obermaier", user.id
assert_equal DateTime.parse("2011-11-04T07:18:00.000Z"), user.created_at
assert_equal "https://nitter.ktachibana.party/pic/pbs.twimg.com%2Fprofile_images%2F1140973306889277440%2Fq3P0CIh6.jpg", user.profile_image_url
assert_equal "Frederik Obermaier", user.name
assert_equal "f_obermaier", user.username
assert_equal "Threema FPN4FKZE | PGP", user.location
assert user.description.include? "journalist"
assert_not_nil user.url
assert_kind_of Integer, user.followers_count
assert_kind_of Integer, user.following_count
assert_kind_of Integer, user.tweet_count
assert_kind_of Integer, user.listed_count
assert user.verified == false
assert user.profile_image_file_name.empty? == false

# Make sure the file is created properly
assert File.exist?(user.profile_image_file_name) && File.file?(user.profile_image_file_name)
end

def test_that_a_user_has_a_url
user = Mosquito::User.lookup("scrippsnews").first
assert_equal "https://www.scrippsnews.com/where-to-watch/", user.url
end

def test_that_a_verified_user_is_probably_marked
user = Mosquito::User.lookup("jack").first
assert user.verified
end

def test_that_a_user_name_is_utf
user = Mosquito::User.lookup("YadavArunesh").first
assert user.name.include? "डॉ अरुणेश यादव"
end
end

0 comments on commit cc848fb

Please sign in to comment.