vk_music 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/Rakefile +5 -0
- data/lib/vk_music.rb +3 -3
- data/lib/vk_music/audio.rb +143 -79
- data/lib/vk_music/client.rb +543 -250
- data/lib/vk_music/constants.rb +78 -33
- data/lib/vk_music/exceptions.rb +14 -17
- data/lib/vk_music/link_decoder.rb +9 -5
- data/lib/vk_music/playlist.rb +47 -36
- data/lib/vk_music/utility.rb +57 -19
- data/test/test_attached_audios_amount.rb +82 -0
- data/test/test_audios.rb +92 -0
- data/test/test_find.rb +43 -0
- data/test/test_from_id.rb +61 -0
- data/test/test_last_post_id.rb +46 -0
- data/test/test_login.rb +1 -1
- data/test/test_page_id.rb +113 -0
- data/test/test_playlist.rb +39 -10
- data/test/test_post.rb +21 -19
- data/test/test_wall.rb +56 -0
- data/vk_music.gemspec +4 -2
- metadata +31 -11
- data/test/test_audios_by_id.rb +0 -49
- data/test/test_get_id.rb +0 -113
- data/test/test_search.rb +0 -30
- data/test/test_user_or_group_audios.rb +0 -77
data/test/test_search.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require_relative "../lib/vk_music.rb"
|
3
|
-
|
4
|
-
begin
|
5
|
-
CLIENT = VkMusic::Client.new(username: ARGV[0], password: ARGV[1])
|
6
|
-
rescue VkMusic::LoginError
|
7
|
-
puts "Unable to login! Please check provided credetionals"
|
8
|
-
exit
|
9
|
-
end
|
10
|
-
|
11
|
-
class TestVkMusic < MiniTest::Test
|
12
|
-
|
13
|
-
def test_search
|
14
|
-
results = CLIENT.find_audio("Rick Astley")
|
15
|
-
refute_empty(results, "There must be some music of Rick Astley")
|
16
|
-
assert_instance_of(VkMusic::Audio, results[0], "Results of search must be of class Audio")
|
17
|
-
refute_empty(results[0].url, "Audio must have download url")
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_search_no_query
|
21
|
-
results = CLIENT.find_audio("")
|
22
|
-
assert_empty(results, "There must be no results for empty query")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_search_no_results
|
26
|
-
results = CLIENT.find_audio("I'm pretty sure no one ever would name a song like this 282E8EE")
|
27
|
-
assert_empty(results, "There must be no results for such query")
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require_relative "../lib/vk_music.rb"
|
3
|
-
|
4
|
-
begin
|
5
|
-
CLIENT = VkMusic::Client.new(username: ARGV[0], password: ARGV[1])
|
6
|
-
rescue VkMusic::LoginError
|
7
|
-
puts "Unable to login! Please check provided credetionals"
|
8
|
-
exit
|
9
|
-
end
|
10
|
-
|
11
|
-
class TestVkMusic < MiniTest::Test
|
12
|
-
|
13
|
-
def test_user
|
14
|
-
pl = CLIENT.get_audios("8024985")
|
15
|
-
assert_instance_of(VkMusic::Playlist, pl, "User audios must be returned as a playlist (cause it is actually is playlist)")
|
16
|
-
refute_empty(pl, "There must be some music")
|
17
|
-
assert_instance_of(VkMusic::Audio, pl[0], "Results must be of class Audio")
|
18
|
-
refute_empty(pl[0].url, "Audio must have download url")
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_user_by_audios_url
|
22
|
-
pl = CLIENT.get_audios("https://m.vk.com/audios8024985")
|
23
|
-
refute_empty(pl, "This user got audios")
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_incorrect_id
|
27
|
-
assert_raises(VkMusic::AudiosParseError) do
|
28
|
-
CLIENT.get_audios("42424242424242424242424242")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_user_with_locked_audios
|
33
|
-
assert_raises(VkMusic::AudiosParseError) do
|
34
|
-
CLIENT.get_audios("152719703")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_user_with_empty_audios
|
39
|
-
pl = CLIENT.get_audios("437727675")
|
40
|
-
assert_empty(pl, "This user got no audios")
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_group
|
44
|
-
pl = CLIENT.get_audios("-4790861")
|
45
|
-
refute_empty(pl, "There must be some music")
|
46
|
-
refute_empty(pl[0].url, "Audio must have download url")
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_group_with_upper_limit_1
|
50
|
-
pl = CLIENT.get_audios("-72589944", 10)
|
51
|
-
assert_equal(10, pl.length, "Size of result must match given limit") # This group got more audios
|
52
|
-
refute_empty(pl[0].url, "Audio must have download url")
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_group_with_upper_limit_2
|
56
|
-
pl = CLIENT.get_audios("-72589944", 200)
|
57
|
-
assert(pl.size <= 200, "Size of result must match given limit")
|
58
|
-
refute_empty(pl[0].url, "Audio must have download url")
|
59
|
-
refute_empty(pl[-1].url, "Audio must have download url")
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_group_with_no_audios
|
63
|
-
pl = CLIENT.get_audios("-52298374")
|
64
|
-
assert_empty(pl, "This group got no audios")
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_group_by_custom_id
|
68
|
-
pl = CLIENT.get_audios("mashup")
|
69
|
-
refute_empty(pl, "This group got audios")
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_group_by_audios_url
|
73
|
-
pl = CLIENT.get_audios("https://m.vk.com/audios-39786657")
|
74
|
-
refute_empty(pl, "This group got audios")
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|