vk_music 2.1.5 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,109 +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_playlist_small_1
14
- pl = CLIENT.playlist("https://vk.com/audio?z=audio_playlist-37661843_1/0e420c32c8b69e6637")
15
- refute_empty(pl, "This playlist must not be empty")
16
- assert_instance_of(VkMusic::Audio, pl[0], "Playlist members must be of class Audio")
17
- refute_empty(pl[0].url, "Audio must have download url")
18
- refute_empty(pl[-1].url, "Audio must have download url")
19
- end
20
-
21
- def test_playlist_small_2
22
- pl = CLIENT.playlist("https://vk.com/music/album/-121725065_1")
23
- refute_empty(pl, "This playlist must not be empty")
24
- assert_instance_of(VkMusic::Audio, pl[0], "Playlist members must be of class Audio")
25
- refute_empty(pl[0].url, "Audio must have download url")
26
- refute_empty(pl[-1].url, "Audio must have download url")
27
- end
28
-
29
- def test_playlist_small_3
30
- pl = CLIENT.playlist("https://vk.com/music/album/-2000637322_637322_e677ea2eab62dc17a8")
31
- refute_empty(pl, "This playlist must not be empty")
32
- assert_instance_of(VkMusic::Audio, pl[0], "Playlist members must be of class Audio")
33
- refute_empty(pl[0].url, "Audio must have download url")
34
- refute_empty(pl[-1].url, "Audio must have download url")
35
- end
36
-
37
- def test_big_url
38
- pl = CLIENT.playlist("https://m.vk.com/audio?act=audio_playlist256492540_83617715&from=search_owned_playlist&access_hash=b8d408241bcfb60583&back_url=%2Faudios-39786657%3Fq%3Dmashup%26tab%3Downed&back_hash=76ef9186ac6f248a27")
39
- refute_empty(pl, "This playlist must not be empty")
40
- assert_instance_of(VkMusic::Audio, pl[0], "Playlist members must be of class Audio")
41
- end
42
-
43
- def test_playlist_small_with_options
44
- pl = CLIENT.playlist(owner_id: -37661843, playlist_id: 1, access_hash: "0e420c32c8b69e6637", with_url: false)
45
- refute_empty(pl, "This playlist must not be empty")
46
- assert_instance_of(VkMusic::Audio, pl[0], "Playlist members must be of class Audio")
47
- assert(pl[0].url_accessable?, "Audio must have all the data needed for getting download URL")
48
- assert(pl[-1].url_accessable?, "Audio must have all the data needed for getting download URL")
49
- end
50
-
51
- def test_playlist_large
52
- pl = CLIENT.playlist("https://vk.com/audio?z=audio_playlist121570739_7")
53
- refute_empty(pl, "This playlist must not be empty")
54
- refute_empty(pl[0].url, "Audio must have download url")
55
- refute_empty(pl[-1].url, "Audio must have download url")
56
- end
57
-
58
- def test_playlist_empty
59
- pl = CLIENT.playlist("https://vk.com/audios437727675?section=playlists&z=audio_playlist437727675_2")
60
- assert_empty(pl, "This playlist must be empty")
61
- end
62
-
63
- def test_playlist_dont_exist
64
- assert_raises(VkMusic::ParseError) do
65
- CLIENT.playlist("https://m.vk.com/audio?act=audio_playlist437727675_300")
66
- end
67
- assert_raises(VkMusic::ParseError) do
68
- CLIENT.playlist("https://m.vk.com/audio?act=audio_playlist437727675_300", with_url: false)
69
- end
70
- end
71
-
72
- def test_playlist_no_access
73
- assert_raises(VkMusic::ParseError) do
74
- CLIENT.playlist("https://m.vk.com/audio?act=audio_playlist1_1")
75
- end
76
- assert_raises(VkMusic::ParseError) do
77
- CLIENT.playlist("https://m.vk.com/audio?act=audio_playlist1_1", with_url: false)
78
- end
79
- end
80
-
81
- def test_playlist_with_upper_limit
82
- pl = CLIENT.playlist("https://vk.com/audio?z=audio_playlist-66223223_77503494", up_to: 105, with_url: true)
83
- assert_equal(105, pl.length, "Size of result must match given limit") # This playlist got more audios
84
- refute_empty(pl[0].url, "Audio must have download url")
85
- refute_empty(pl[-1].url, "Audio must have download url")
86
- end
87
-
88
- def test_playlist_without_url
89
- pl = CLIENT.playlist("https://vk.com/audio?z=audio_playlist121570739_7", with_url: false)
90
- assert(pl[0].url_accessable?, "Audio must have all the data needed for getting download URL")
91
- assert(pl[-1].url_accessable?, "Audio must have all the data needed for getting download URL")
92
- end
93
-
94
- def test_bad_url
95
- assert_raises(ArgumentError) do
96
- CLIENT.playlist("ae")
97
- end
98
- assert_raises(ArgumentError) do
99
- CLIENT.playlist("ae", with_url: false)
100
- end
101
- end
102
-
103
- def test_bad_arg
104
- assert_raises(ArgumentError) do
105
- CLIENT.playlist("ae", "bc")
106
- end
107
- end
108
-
109
- end
data/test/test_post.rb DELETED
@@ -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_single_audio
14
- audios = CLIENT.post("https://vk.com/wall-184089233_6")
15
- assert_instance_of(Array, audios, "Result must be of class Array")
16
- assert_equal(1, audios.length, "This post got 1 attached audio")
17
- assert_instance_of(VkMusic::Audio, audios[0], "Array must consist of class Audio")
18
- refute_empty(audios[0].url, "Audio must have download url")
19
- end
20
-
21
- def test_single_audio_with_options
22
- audios = CLIENT.post(owner_id: -184089233, post_id: 6)
23
- assert_instance_of(Array, audios, "Result must be of class Array")
24
- assert_equal(1, audios.length, "This post got 1 attached audio")
25
- assert_instance_of(VkMusic::Audio, audios[0], "Array must consist of class Audio")
26
- refute_empty(audios[0].url, "Audio must have download url")
27
- end
28
-
29
- def test_no_audio
30
- audios = CLIENT.post("https://vk.com/wall-184089233_2")
31
- assert_empty(audios, "This post got no attached audio")
32
- end
33
-
34
- def test_url_to_reply
35
- audios = CLIENT.post("https://m.vk.com/wall-4790861_10108")
36
- assert_equal(1, audios.length, "Although this link redirects to comment, audios from post must be parsed")
37
- end
38
-
39
- def test_playlist
40
- audios = CLIENT.post("vk.com/wall-184089233_4")
41
- assert_empty(audios, "This post got attached playlist but those audios must not be parsed")
42
- end
43
-
44
- def test_comments_with_audios
45
- audios = CLIENT.post("https://m.vk.com/wall-39786657_189247")
46
- assert_equal(1, audios.length, "This post got comments with audios but those audios must not be parsed")
47
- end
48
-
49
- def test_repost_with_no_audios
50
- audios = CLIENT.post("https://vk.com/wall-184936953_1")
51
- assert_empty(audios, "This post got no attached audios")
52
- end
53
-
54
- def test_repost_with_audios
55
- audios = CLIENT.post("https://vk.com/wall-184936953_2")
56
- assert_equal(1, audios.length, "This repost got 1 attached audio")
57
- refute_empty(audios[0].url, "Audio must have download url")
58
- end
59
-
60
- def test_repost_with_playlist
61
- audios = CLIENT.post("https://vk.com/wall-184936953_3")
62
- assert_empty(audios, "This post got no attached audios")
63
- end
64
-
65
- def test_bad_url
66
- assert_raises(ArgumentError) do
67
- CLIENT.post("ae")
68
- end
69
- end
70
-
71
- def test_nonexistent_post
72
- assert_raises(VkMusic::ParseError) do
73
- CLIENT.post("https://m.vk.com/wall-4790861_1052600000")
74
- end
75
- end
76
-
77
- end
data/test/test_wall.rb DELETED
@@ -1,56 +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_url_1
14
- arr = CLIENT.wall("https://vk.com/mashup", up_to: 10)
15
- assert_instance_of(Array, arr, "Result must be an array")
16
- refute_empty(arr, "There must be something on the wall")
17
- assert_equal(10, arr.size, "Size must be exactly the given")
18
- assert_instance_of(VkMusic::Audio, arr[0], "Playlist members must be of class Audio")
19
- refute_empty(arr[0].url, "Audio must have download url")
20
- refute_empty(arr[-1].url, "Audio must have download url")
21
- end
22
-
23
- def test_url_2
24
- arr = CLIENT.wall("https://vk.com/mashup", with_url: false)
25
- refute_empty(arr, "There must be something on the wall")
26
- assert_instance_of(VkMusic::Audio, arr[0], "Playlist members must be of class Audio")
27
- assert(arr[0].url_accessable?, "Audio must have accessable URL")
28
- assert(arr[-1].url_accessable?, "Audio must have accessable URL")
29
- end
30
-
31
- def test_ids
32
- arr = CLIENT.wall(owner_id: -39786657, post_id: 204102, with_url: false)
33
- refute_empty(arr, "There must be something on the wall")
34
- assert_instance_of(VkMusic::Audio, arr[0], "Playlist members must be of class Audio")
35
- assert(arr[0].url_accessable?, "Audio must have accessable URL")
36
- assert(arr[-1].url_accessable?, "Audio must have accessable URL")
37
- end
38
-
39
- def test_empty_wall
40
- arr = CLIENT.wall("https://vk.com/club185224844")
41
- assert_empty(arr, "This wall is empty")
42
- end
43
-
44
- def test_bad_url
45
- assert_raises(VkMusic::ParseError) do
46
- CLIENT.wall("abc")
47
- end
48
- end
49
-
50
- def test_not_accessable_page
51
- assert_raises(VkMusic::ParseError) do
52
- CLIENT.wall("https://vk.com/club2")
53
- end
54
- end
55
-
56
- end