Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3634 – Refactor Kwai testing #399

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/integration/parsers/kwai_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'test_helper'

class KwaiIntegrationTest < ActiveSupport::TestCase
test "should parse Kwai URL" do
m = create_media url: 'https://kwai-video.com/p/md02RsCS'
data = m.as_json

assert_kind_of String, data['title']
assert_kind_of String, data['description']
assert_equal 'Arthur Virgilio', data['username']
assert_equal 'Arthur Virgilio', data['author_name']
assert_equal 'kwai', data['provider']
assert_equal 'item', data['type']
end

test "should return data even if Kwai URL does not exist" do
m = create_media url: 'https://kwai-video.com/p/aaaaaaaa'
data = m.as_json

assert_equal 'https://kwai-video.com/p/aaaaaaaa', data['title']
assert data['description'].blank?
assert data['username'].blank?
assert_equal 'kwai', data['provider']
assert_equal 'item', data['type']
assert_nil data['error']
end
end
19 changes: 2 additions & 17 deletions test/models/parser/kwai_test.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
require 'test_helper'

class KwaiIntegrationTest < ActiveSupport::TestCase
test "should parse Kwai URL" do
m = create_media url: 'https://kwai-video.com/p/md02RsCS'
data = m.as_json

assert_equal 'Arthur Virgilio', data['username']
assert_equal 'item', data['type']
assert_equal 'kwai', data['provider']
assert_equal 'Arthur Virgilio', data['author_name']
assert_kind_of String, data['title']
assert_kind_of String, data['description']
assert_nil data['error']
end
end

class KwaiUnitTest < ActiveSupport::TestCase
def setup
isolated_setup
Expand All @@ -30,7 +15,7 @@ def teardown

test "matches known kwai URL patterns, and returns instance on success" do
assert_nil Parser::KwaiItem.match?('https://example.com')

match_one = Parser::KwaiItem.match?('https://s.kw.ai/p/1mCb9SSh')
assert_equal true, match_one.is_a?(Parser::KwaiItem)
match_two = Parser::KwaiItem.match?('https://m.kwai.com/photo/150000228494834/5222636779124848117')
Expand All @@ -40,7 +25,7 @@ def teardown
match_four = Parser::KwaiItem.match?('https://www.kwai.com/@AnonymouSScobar/video/5217288797260590112?page_source=guest_profile')
assert_equal true, match_four.is_a?(Parser::KwaiItem)
end

test "does not match kwai profile URL" do
match_five = Parser::PageItem.match?('https://www.kwai.com/@AnonymouSScobar')
assert_equal false, match_five.is_a?(Parser::KwaiItem)
Expand Down
Loading