rbrainz 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -1
- data/Rakefile +2 -2
- data/lib/rbrainz/model/mbid.rb +3 -11
- data/lib/rbrainz/model/relateable.rb +2 -1
- data/lib/rbrainz/utils/helper.rb +10 -1
- data/lib/rbrainz/version.rb +2 -2
- data/lib/rbrainz/webservice/webservice.rb +2 -1
- data/test/lib/test_rateable.rb +3 -3
- data/test/test-data/valid/artist/Tori_Amos_2.xml +14 -0
- data/test/test-data/valid/release-group/search_result_1.xml +23 -0
- data/test/test-data/valid/release/Under_the_Pink_2.xml +3 -0
- data/test/test_mbid.rb +8 -8
- data/test/test_mbxml.rb +33 -1
- data/test/test_track.rb +3 -3
- data/test/test_utils.rb +58 -1
- metadata +27 -26
data/CHANGES
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
== 0.5.1 (2009-08-04)
|
4
|
+
* BUG: Fixed querying for release groups
|
5
|
+
|
3
6
|
== 0.5.0 (2009-06-14)
|
4
7
|
* NEW: Support for release groups
|
5
8
|
* NEW: Support for ISRCs, including ISRC submission
|
@@ -77,4 +80,4 @@
|
|
77
80
|
== 0.1.0 (2007-05-23)
|
78
81
|
* Initial release
|
79
82
|
|
80
|
-
$Id: CHANGES
|
83
|
+
$Id: CHANGES 290 2009-08-04 16:34:54Z phw $
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: Rakefile
|
2
|
+
# $Id: Rakefile 291 2009-08-04 16:43:22Z phw $
|
3
3
|
# Copyright (c) 2007, Philipp Wolfer
|
4
4
|
# All rights reserved.
|
5
5
|
# See LICENSE for permissions.
|
@@ -25,7 +25,7 @@ PKG_FILES = FileList[
|
|
25
25
|
"examples/**/*.rb",
|
26
26
|
"lib/**/*.rb",
|
27
27
|
"test/**/*.rb",
|
28
|
-
"test/test-data/**/*"
|
28
|
+
"test/test-data/**/*"
|
29
29
|
]
|
30
30
|
PKG_EXTRA_RDOC_FILES = ['doc/README.rdoc', 'LICENSE', 'TODO', 'CHANGES']
|
31
31
|
|
data/lib/rbrainz/model/mbid.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: mbid.rb
|
2
|
+
# $Id: mbid.rb 288 2009-08-04 12:50:09Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -106,10 +106,10 @@ module MusicBrainz
|
|
106
106
|
unless is_valid_entity_type_or_nil(entity_type)
|
107
107
|
raise UnknownEntityError, entity_type
|
108
108
|
end
|
109
|
-
entity_type = entity_type_to_symbol(entity_type)
|
109
|
+
entity_type = Utils.entity_type_to_symbol(entity_type)
|
110
110
|
|
111
111
|
if str =~ ENTITY_URI_REGEXP
|
112
|
-
@entity = entity_type_to_symbol($1)
|
112
|
+
@entity = Utils.entity_type_to_symbol($1)
|
113
113
|
@uuid = $2.downcase
|
114
114
|
unless entity_type.nil? || @entity == entity_type
|
115
115
|
raise EntityTypeNotMatchingError, "#{@entity}, #{entity_type}"
|
@@ -158,14 +158,6 @@ module MusicBrainz
|
|
158
158
|
return entity_type.nil? || Utils.entity_type_to_string(entity_type) =~ ENTITY_TYPE_REGEXP
|
159
159
|
end
|
160
160
|
|
161
|
-
def entity_type_to_symbol(entity_type)
|
162
|
-
unless entity_type.respond_to? :to_sym
|
163
|
-
return entity_type
|
164
|
-
end
|
165
|
-
entity_type = entity_type.to_sym
|
166
|
-
return entity_type.to_s.sub('-', '_').to_sym
|
167
|
-
end
|
168
|
-
|
169
161
|
end
|
170
162
|
|
171
163
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: relateable.rb
|
2
|
+
# $Id: relateable.rb 286 2009-08-04 12:03:43Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2009, Philipp Wolfer
|
6
6
|
# License:: RBrainz is free software distributed under a BSD style license.
|
7
7
|
# See LICENSE[file:../LICENSE.html] for permissions.
|
8
8
|
|
9
|
+
require 'set'
|
9
10
|
require 'rbrainz/model/relation'
|
10
11
|
require 'rbrainz/model/collection'
|
11
12
|
|
data/lib/rbrainz/utils/helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: helper.rb
|
2
|
+
# $Id: helper.rb 288 2009-08-04 12:50:09Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Nigel Graham, Philipp Wolfer
|
5
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -37,6 +37,15 @@ module MusicBrainz
|
|
37
37
|
return entity_type.to_s.sub('_', '-')
|
38
38
|
end
|
39
39
|
|
40
|
+
# Converts an entity type string into the proper symbol
|
41
|
+
def entity_type_to_symbol(entity_type)
|
42
|
+
unless entity_type.respond_to? :to_sym
|
43
|
+
return entity_type
|
44
|
+
end
|
45
|
+
entity_type = entity_type.to_sym
|
46
|
+
return entity_type.to_s.sub('-', '_').to_sym
|
47
|
+
end
|
48
|
+
|
40
49
|
# Check an options hash for required options.
|
41
50
|
# Raises an ArgumentError if unknown options are present in the hash.
|
42
51
|
def check_options(options, *optdecl) # :nodoc:
|
data/lib/rbrainz/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: version.rb
|
2
|
+
# $Id: version.rb 290 2009-08-04 16:34:54Z phw $
|
3
3
|
#
|
4
4
|
# Version information.
|
5
5
|
#
|
@@ -11,6 +11,6 @@
|
|
11
11
|
module MusicBrainz
|
12
12
|
|
13
13
|
# The version of the RBrainz library.
|
14
|
-
RBRAINZ_VERSION = '0.5.
|
14
|
+
RBRAINZ_VERSION = '0.5.1'
|
15
15
|
|
16
16
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: webservice.rb
|
1
|
+
# $Id: webservice.rb 289 2009-08-04 12:52:31Z phw $
|
2
2
|
#
|
3
3
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
4
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -153,6 +153,7 @@ module MusicBrainz
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def build_uri_without_querystring(entity_type, options)
|
156
|
+
entity_type = Utils.entity_type_to_string(entity_type)
|
156
157
|
if options[:id]
|
157
158
|
# Make sure the id is a MBID object
|
158
159
|
id = options[:id]
|
data/test/lib/test_rateable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: test_rateable.rb
|
2
|
+
# $Id: test_rateable.rb 285 2009-08-04 12:00:34Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2009, Philipp Wolfer
|
@@ -18,13 +18,13 @@ module TestRateable
|
|
18
18
|
|
19
19
|
def test_class_has_empty_rating
|
20
20
|
entity = @tested_class.new
|
21
|
-
assert entity.rating.is_a?
|
21
|
+
assert entity.rating.is_a?(Model::Rating)
|
22
22
|
assert entity.rating.empty?
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_class_has_empty_user_rating
|
26
26
|
entity = @tested_class.new
|
27
|
-
assert entity.user_rating.is_a?
|
27
|
+
assert entity.user_rating.is_a?(Model::Rating)
|
28
28
|
assert entity.user_rating.empty?
|
29
29
|
end
|
30
30
|
|
@@ -8,6 +8,7 @@
|
|
8
8
|
<release id="a7ccb022-f437-4492-8eee-8f85d85cdb96" type="Album Official">
|
9
9
|
<title>Strange Little Girls</title>
|
10
10
|
<asin>B00005NKYQ</asin>
|
11
|
+
<release-group id="a69a1574-dfe3-3e2a-b499-d26d5e916041"/>
|
11
12
|
<release-event-list>
|
12
13
|
<event date="2001-09-14" country="BE"/>
|
13
14
|
<event date="2001-09-14" country="FI"/>
|
@@ -28,6 +29,7 @@
|
|
28
29
|
<title>To Venus and Back (disc 1: Orbiting)</title>
|
29
30
|
<asin>B00001IVJS</asin>
|
30
31
|
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5"/>
|
32
|
+
<release-group id="1fd43909-8056-3805-b2f9-c663ce7e71e6"/>
|
31
33
|
<release-event-list>
|
32
34
|
<event date="1999-09-20" country="DE"/>
|
33
35
|
<event date="1999-09-20" country="GB"/>
|
@@ -39,6 +41,7 @@
|
|
39
41
|
<title>Under the Pink</title>
|
40
42
|
<asin>B000002IXU</asin>
|
41
43
|
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5"/>
|
44
|
+
<release-group id="ef2b891f-ca73-3e14-b38b-a68699dab8c4"/>
|
42
45
|
<release-event-list>
|
43
46
|
<event date="1994-01-28" country="DE"/>
|
44
47
|
<event date="1994-01-31" country="GB"/>
|
@@ -49,5 +52,16 @@
|
|
49
52
|
<disc-list count="4"/>
|
50
53
|
</release>
|
51
54
|
</release-list>
|
55
|
+
<release-group-list>
|
56
|
+
<release-group id="ef2b891f-ca73-3e14-b38b-a68699dab8c4" type="Album">
|
57
|
+
<title>Under the Pink</title>
|
58
|
+
</release-group>
|
59
|
+
<release-group id="1fd43909-8056-3805-b2f9-c663ce7e71e6" type="Album">
|
60
|
+
<title>To Venus and Back</title>
|
61
|
+
</release-group>
|
62
|
+
<release-group id="a69a1574-dfe3-3e2a-b499-d26d5e916041" type="Album">
|
63
|
+
<title>Strange Little Girls</title>
|
64
|
+
</release-group>
|
65
|
+
</release-group-list>
|
52
66
|
</artist>
|
53
67
|
</metadata>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#" xmlns:ext="http://musicbrainz.org/ns/ext-1.0#">
|
3
|
+
<release-group-list count="3" offset="0">
|
4
|
+
<release-group id="963eac15-e3da-3a92-aa5c-2ec23bfb6ec2" type="Album" ext:score="100">
|
5
|
+
<title>Signal Morning</title>
|
6
|
+
<artist id="2dea8a55-623b-42bb-bda3-9fb784018b40">
|
7
|
+
<name>Circulatory System</name>
|
8
|
+
</artist>
|
9
|
+
</release-group>
|
10
|
+
<release-group id="0bd324a3-1c90-3bdb-8ca4-4101a580c62c" type="Album" ext:score="98">
|
11
|
+
<title>Circulatory System</title>
|
12
|
+
<artist id="2dea8a55-623b-42bb-bda3-9fb784018b40">
|
13
|
+
<name>Circulatory System</name>
|
14
|
+
</artist>
|
15
|
+
</release-group>
|
16
|
+
<release-group id="ea7d8352-7751-30be-8490-bb6df737f47c" type="Album" ext:score="90">
|
17
|
+
<title>Inside Views</title>
|
18
|
+
<artist id="2dea8a55-623b-42bb-bda3-9fb784018b40">
|
19
|
+
<name>Circulatory System</name>
|
20
|
+
</artist>
|
21
|
+
</release-group>
|
22
|
+
</release-group-list>
|
23
|
+
</metadata>
|
@@ -5,6 +5,9 @@
|
|
5
5
|
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
6
6
|
<name>Tori Amos</name>
|
7
7
|
</artist>
|
8
|
+
<release-group id="ef2b891f-ca73-3e14-b38b-a68699dab8c4" type="Album">
|
9
|
+
<title>Under the Pink</title>
|
10
|
+
</release-group>
|
8
11
|
<track-list offset="1" count="12">
|
9
12
|
<track id="0a984e3b-e38a-4b86-80be-f3a3eb1114ca">
|
10
13
|
<title>God</title>
|
data/test/test_mbid.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: test_mbid.rb
|
2
|
+
# $Id: test_mbid.rb 288 2009-08-04 12:50:09Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2007, Philipp Wolfer
|
@@ -14,8 +14,8 @@ include MusicBrainz
|
|
14
14
|
class TestMBID < Test::Unit::TestCase
|
15
15
|
|
16
16
|
def setup
|
17
|
-
@valid_entities = [:artist, :release, :track, :label,
|
18
|
-
'artist', 'release', 'track', 'label']
|
17
|
+
@valid_entities = [:artist, :release, :track, :label, :release_group,
|
18
|
+
'artist', 'release', 'track', 'label', 'release-group']
|
19
19
|
@valid_uuids = ['9d30e408-1559-448b-b491-2f8de1583ccf']
|
20
20
|
@invalid_uris = [nil, '', 'http://musicbrainz.org/labels/727ad90b-7ef4-48d2-8f16-c34016544822',
|
21
21
|
'http://musicbrainz.org/label/727ad90b-7ef4-48d2-8f16-c34016544822?']
|
@@ -49,7 +49,7 @@ class TestMBID < Test::Unit::TestCase
|
|
49
49
|
@valid_entities.each{|entity|
|
50
50
|
@valid_uuids.each{|uuid|
|
51
51
|
assert_nothing_raised \
|
52
|
-
{Model::MBID.parse 'http://musicbrainz.org/' +
|
52
|
+
{Model::MBID.parse 'http://musicbrainz.org/' + Utils.entity_type_to_string(entity) + '/' + uuid }
|
53
53
|
}
|
54
54
|
}
|
55
55
|
@invalid_uris.each{|uri|
|
@@ -76,7 +76,7 @@ class TestMBID < Test::Unit::TestCase
|
|
76
76
|
def test_to_s
|
77
77
|
@valid_entities.each{|entity|
|
78
78
|
@valid_uuids.each{|uuid|
|
79
|
-
uri = 'http://musicbrainz.org/' + entity
|
79
|
+
uri = 'http://musicbrainz.org/' + Utils.entity_type_to_string(entity) + '/' + uuid
|
80
80
|
mbid = Model::MBID.parse uuid, entity
|
81
81
|
assert_equal uri, mbid.to_s
|
82
82
|
mbid = Model::MBID.parse uri
|
@@ -89,10 +89,10 @@ class TestMBID < Test::Unit::TestCase
|
|
89
89
|
@valid_entities.each{|entity|
|
90
90
|
@valid_uuids.each{|uuid|
|
91
91
|
mbid = Model::MBID.parse uuid, entity
|
92
|
-
assert_equal entity
|
92
|
+
assert_equal Utils.entity_type_to_symbol(entity), mbid.entity
|
93
93
|
assert_equal uuid, mbid.uuid
|
94
|
-
mbid = Model::MBID.parse 'http://musicbrainz.org/' + entity
|
95
|
-
assert_equal entity
|
94
|
+
mbid = Model::MBID.parse 'http://musicbrainz.org/' + Utils.entity_type_to_string(entity) + '/' + uuid
|
95
|
+
assert_equal Utils.entity_type_to_symbol(entity), mbid.entity
|
96
96
|
assert_equal uuid, mbid.uuid
|
97
97
|
}
|
98
98
|
}
|
data/test/test_mbxml.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: test_mbxml.rb
|
2
|
+
# $Id: test_mbxml.rb 292 2009-08-04 17:06:18Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -132,13 +132,20 @@ class TestMBXML < Test::Unit::TestCase
|
|
132
132
|
assert_equal 3, artist.releases.size
|
133
133
|
assert_equal 'a7ccb022-f437-4492-8eee-8f85d85cdb96', artist.releases[0].id.uuid
|
134
134
|
assert_equal artist, artist.releases[0].artist
|
135
|
+
assert_equal 'a69a1574-dfe3-3e2a-b499-d26d5e916041', artist.releases[0].release_group.id.uuid
|
135
136
|
assert_equal 3, artist.releases[0].discs.count
|
136
137
|
assert_equal '9cbf7040-dbdc-403c-940f-7562d9712514', artist.releases[1].id.uuid
|
137
138
|
assert_equal artist, artist.releases[1].artist
|
139
|
+
assert_equal '1fd43909-8056-3805-b2f9-c663ce7e71e6', artist.releases[1].release_group.id.uuid
|
138
140
|
assert_equal 2, artist.releases[1].discs.count
|
139
141
|
assert_equal '290e10c5-7efc-4f60-ba2c-0dfc0208fbf5', artist.releases[2].id.uuid
|
140
142
|
assert_equal artist, artist.releases[2].artist
|
143
|
+
assert_equal 'ef2b891f-ca73-3e14-b38b-a68699dab8c4', artist.releases[2].release_group.id.uuid
|
141
144
|
assert_equal 4, artist.releases[2].discs.count
|
145
|
+
assert_equal 3, artist.release_groups.size
|
146
|
+
assert_equal artist.release_groups[0], artist.releases[2].release_group
|
147
|
+
assert_equal artist.release_groups[1], artist.releases[1].release_group
|
148
|
+
assert_equal artist.release_groups[2], artist.releases[0].release_group
|
142
149
|
end
|
143
150
|
|
144
151
|
def test_artist_tori_amos_3
|
@@ -202,6 +209,28 @@ class TestMBXML < Test::Unit::TestCase
|
|
202
209
|
assert artist.releases[0].types.include?(Model::Release::TYPE_OFFICIAL)
|
203
210
|
end
|
204
211
|
|
212
|
+
def test_release_group_search
|
213
|
+
mbxml = Webservice::MBXML.new File.new(DATA_PATH + 'release-group/search_result_1.xml')
|
214
|
+
assert_equal nil, mbxml.get_entity(:artist)
|
215
|
+
assert_equal nil, mbxml.get_entity(:release)
|
216
|
+
assert_equal nil, mbxml.get_entity(:track)
|
217
|
+
assert_equal nil, mbxml.get_entity(:label)
|
218
|
+
assert_equal nil, mbxml.get_entity(:release_group)
|
219
|
+
|
220
|
+
release_group_list = mbxml.get_entity_list(:release_group)
|
221
|
+
assert_equal 0, release_group_list.offset
|
222
|
+
assert_equal 3, release_group_list.count
|
223
|
+
|
224
|
+
assert_equal 3, release_group_list.size, release_group_list.inspect
|
225
|
+
assert_equal '963eac15-e3da-3a92-aa5c-2ec23bfb6ec2', release_group_list[0].entity.id.uuid
|
226
|
+
assert release_group_list[0].entity.types.include?(Model::ReleaseGroup::TYPE_ALBUM)
|
227
|
+
assert_equal 'Signal Morning', release_group_list[0].entity.title
|
228
|
+
assert_equal '2dea8a55-623b-42bb-bda3-9fb784018b40', release_group_list[0].entity.artist.id.uuid
|
229
|
+
assert_equal 'Circulatory System', release_group_list[0].entity.artist.name
|
230
|
+
assert_equal 100, release_group_list[0].score
|
231
|
+
assert_equal 98, release_group_list[1].score
|
232
|
+
end
|
233
|
+
|
205
234
|
def test_release_group_the_cure_1
|
206
235
|
mbxml = Webservice::MBXML.new File.new(DATA_PATH + 'release-group/The_Cure_1.xml')
|
207
236
|
release_group = mbxml.get_entity(:release_group)
|
@@ -403,6 +432,9 @@ class TestMBXML < Test::Unit::TestCase
|
|
403
432
|
assert_equal 1, release.tracks.size
|
404
433
|
assert_equal '0a984e3b-e38a-4b86-80be-f3a3eb1114ca', release.tracks[0].id.uuid
|
405
434
|
assert_equal 'God', release.tracks[0].title
|
435
|
+
assert_equal 'ef2b891f-ca73-3e14-b38b-a68699dab8c4', release.release_group.id.uuid
|
436
|
+
assert release.release_group.types.include?(Model::ReleaseGroup::TYPE_ALBUM)
|
437
|
+
assert_equal 'Under the Pink', release.release_group.title
|
406
438
|
end
|
407
439
|
|
408
440
|
def test_release_under_the_pink_3
|
data/test/test_track.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: test_track.rb
|
2
|
+
# $Id: test_track.rb 285 2009-08-04 12:00:34Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2007, Philipp Wolfer
|
@@ -78,7 +78,7 @@ class TestTrack < Test::Unit::TestCase
|
|
78
78
|
# Many PUIDs can be added
|
79
79
|
def test_add_and_remove_puids
|
80
80
|
track = Model::Track.new
|
81
|
-
assert track.puids.is_a?
|
81
|
+
assert track.puids.is_a?(Model::Collection)
|
82
82
|
assert_equal 0, track.puids.size
|
83
83
|
assert_nothing_raised {track.puids << @valid_puids[0]}
|
84
84
|
assert_equal 1, track.puids.size
|
@@ -94,7 +94,7 @@ class TestTrack < Test::Unit::TestCase
|
|
94
94
|
# Many ISRCs can be added
|
95
95
|
def test_add_and_remove_isrcs
|
96
96
|
track = Model::Track.new
|
97
|
-
assert track.isrcs.is_a?
|
97
|
+
assert track.isrcs.is_a?(Model::Collection)
|
98
98
|
assert_equal 0, track.isrcs.size
|
99
99
|
assert_nothing_raised {track.isrcs << @valid_isrcs[0]}
|
100
100
|
assert_equal 1, track.isrcs.size
|
data/test/test_utils.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# $Id: test_utils.rb
|
2
|
+
# $Id: test_utils.rb 288 2009-08-04 12:50:09Z phw $
|
3
3
|
#
|
4
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
5
|
# Copyright:: Copyright (c) 2007, Philipp Wolfer
|
@@ -39,4 +39,61 @@ class TestUtils < Test::Unit::TestCase
|
|
39
39
|
assert_equal nil, Utils.get_release_type_name('UNKNOWN')
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_add_default_namespace
|
43
|
+
name = 'Group'
|
44
|
+
name_with_ns = Model::NS_MMD_1 + name
|
45
|
+
assert_equal name_with_ns, Utils.add_namespace(name)
|
46
|
+
assert_equal name_with_ns, Utils.add_namespace(name_with_ns)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_add_custom_namespace
|
50
|
+
namespace = 'http://test.musicbrainz.org/ns/mmd-1.0#'
|
51
|
+
name = 'Group'
|
52
|
+
name_with_ns = namespace + name
|
53
|
+
assert_equal name_with_ns, Utils.add_namespace(name, namespace)
|
54
|
+
assert_equal name_with_ns, Utils.add_namespace(name_with_ns, namespace)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_remove_default_namespace
|
58
|
+
name = 'Group'
|
59
|
+
name_with_ns = Model::NS_MMD_1 + name
|
60
|
+
assert_equal name, Utils.remove_namespace(name_with_ns)
|
61
|
+
assert_equal name, Utils.remove_namespace(name)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_remove_custom_namespace
|
65
|
+
namespace = 'http://test.musicbrainz.org/ns/mmd-1.0#'
|
66
|
+
name = 'Group'
|
67
|
+
name_with_ns = namespace + name
|
68
|
+
assert_equal name, Utils.remove_namespace(name_with_ns, namespace)
|
69
|
+
assert_equal name, Utils.remove_namespace(name, namespace)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_entity_type_to_string
|
73
|
+
entity_type_symbol = Model::ReleaseGroup::ENTITY_TYPE
|
74
|
+
entity_type_string = 'release-group'
|
75
|
+
result = Utils.entity_type_to_string(entity_type_symbol)
|
76
|
+
assert_equal entity_type_string, result
|
77
|
+
assert result.is_a?(String), "Result is not a string."
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_entity_type_to_symbol
|
81
|
+
entity_type_symbol = Model::ReleaseGroup::ENTITY_TYPE
|
82
|
+
entity_type_string = 'release-group'
|
83
|
+
result = Utils.entity_type_to_symbol(entity_type_string)
|
84
|
+
assert_equal entity_type_symbol, result
|
85
|
+
assert result.is_a?(Symbol), "Result is not a symbol."
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_check_options_with_valid_options
|
89
|
+
given_options = { :query => '', :offset => 2, :name => 'Test', :limit => 1 }
|
90
|
+
assert_nothing_raised { Utils.check_options given_options, :limit, :offset, :query, :name }
|
91
|
+
assert_nothing_raised { Utils.check_options given_options, :limit, :offset, :query, :name, :extra_option }
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_check_options_with_invalid_options
|
95
|
+
given_options = { :limit => 1, :offset => 2, :bad_option => '', :name => 'Test' }
|
96
|
+
assert_raise(ArgumentError) { Utils.check_options given_options, :limit, :offset, :query, :name }
|
97
|
+
end
|
98
|
+
|
42
99
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbrainz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Wolfer
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-08-04 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- CHANGES
|
34
34
|
- setup.rb
|
35
35
|
- doc/README.rdoc
|
36
|
+
- examples/searchreleasegroups.rb
|
36
37
|
- examples/getreleasegroup.rb
|
37
38
|
- examples/searchcdstubs.rb
|
38
39
|
- examples/searchtracks.rb
|
@@ -42,34 +43,33 @@ files:
|
|
42
43
|
- examples/getrelease.rb
|
43
44
|
- examples/gettrack.rb
|
44
45
|
- examples/getartist.rb
|
45
|
-
- examples/
|
46
|
+
- examples/searchreleases.rb
|
46
47
|
- examples/submit_isrcs.rb
|
47
48
|
- examples/searchlabels.rb
|
48
|
-
- examples/searchreleases.rb
|
49
49
|
- examples/rate.rb
|
50
50
|
- examples/tag.rb
|
51
|
+
- lib/rbrainz/model/release_event.rb
|
51
52
|
- lib/rbrainz/model/relation.rb
|
52
53
|
- lib/rbrainz/model/user.rb
|
53
54
|
- lib/rbrainz/model/label.rb
|
54
55
|
- lib/rbrainz/model/rateable.rb
|
55
56
|
- lib/rbrainz/model/release.rb
|
56
|
-
- lib/rbrainz/model/release_event.rb
|
57
|
-
- lib/rbrainz/model/disc.rb
|
58
57
|
- lib/rbrainz/model/rating.rb
|
58
|
+
- lib/rbrainz/model/disc.rb
|
59
|
+
- lib/rbrainz/model/scored_collection.rb
|
59
60
|
- lib/rbrainz/model/individual.rb
|
60
61
|
- lib/rbrainz/model/alias.rb
|
61
|
-
- lib/rbrainz/model/
|
62
|
+
- lib/rbrainz/model/incomplete_date.rb
|
62
63
|
- lib/rbrainz/model/collection.rb
|
63
64
|
- lib/rbrainz/model/release_group.rb
|
64
|
-
- lib/rbrainz/model/
|
65
|
+
- lib/rbrainz/model/artist.rb
|
65
66
|
- lib/rbrainz/model/isrc.rb
|
66
|
-
- lib/rbrainz/model/relateable.rb
|
67
67
|
- lib/rbrainz/model/track.rb
|
68
|
-
- lib/rbrainz/model/
|
68
|
+
- lib/rbrainz/model/relateable.rb
|
69
69
|
- lib/rbrainz/model/taggable.rb
|
70
70
|
- lib/rbrainz/model/mbid.rb
|
71
|
-
- lib/rbrainz/model/default_factory.rb
|
72
71
|
- lib/rbrainz/model/tag.rb
|
72
|
+
- lib/rbrainz/model/default_factory.rb
|
73
73
|
- lib/rbrainz/model/entity.rb
|
74
74
|
- lib/rbrainz/utils/helper.rb
|
75
75
|
- lib/rbrainz/utils/data.rb
|
@@ -92,45 +92,45 @@ files:
|
|
92
92
|
- lib/rbrainz/version.rb
|
93
93
|
- lib/rbrainz/core_ext.rb
|
94
94
|
- lib/rbrainz.rb
|
95
|
-
- test/lib/test_rateable.rb
|
96
95
|
- test/lib/test_relateable.rb
|
96
|
+
- test/lib/test_rateable.rb
|
97
|
+
- test/lib/mock_webservice.rb
|
97
98
|
- test/lib/test_taggable.rb
|
98
99
|
- test/lib/test_factory.rb
|
99
|
-
- test/lib/mock_webservice.rb
|
100
|
-
- test/lib/test_entity.rb
|
101
100
|
- test/lib/testing_helper.rb
|
101
|
+
- test/lib/test_entity.rb
|
102
|
+
- test/test_label_filter.rb
|
102
103
|
- test/test_label.rb
|
103
104
|
- test/test_mbxml.rb
|
104
105
|
- test/test_disc.rb
|
105
106
|
- test/test_rating.rb
|
106
|
-
- test/
|
107
|
+
- test/test_release_group_filter.rb
|
107
108
|
- test/test_release_filter.rb
|
108
109
|
- test/test_track_includes.rb
|
109
110
|
- test/test_artist_includes.rb
|
110
111
|
- test/test_webservice.rb
|
111
112
|
- test/test_utils.rb
|
112
113
|
- test/test_isrc.rb
|
113
|
-
- test/
|
114
|
+
- test/test_collection.rb
|
114
115
|
- test/test_track.rb
|
115
|
-
- test/test_label_includes.rb
|
116
116
|
- test/test_query.rb
|
117
|
+
- test/test_label_includes.rb
|
117
118
|
- test/test_artist.rb
|
119
|
+
- test/test_tag.rb
|
118
120
|
- test/test_release_includes.rb
|
119
121
|
- test/test_range_equality.rb
|
120
|
-
- test/test_tag.rb
|
121
122
|
- test/test_relation.rb
|
122
123
|
- test/test_release.rb
|
124
|
+
- test/test_alias.rb
|
123
125
|
- test/test_release_event.rb
|
126
|
+
- test/test_mbid.rb
|
124
127
|
- test/test_release_group_includes.rb
|
125
|
-
- test/test_alias.rb
|
126
128
|
- test/test_scored_collection.rb
|
127
|
-
- test/test_collection.rb
|
128
129
|
- test/test_incomplete_date.rb
|
129
130
|
- test/test_release_group.rb
|
130
131
|
- test/test_track_filter.rb
|
131
132
|
- test/test_default_factory.rb
|
132
133
|
- test/test_artist_filter.rb
|
133
|
-
- test/test_mbid.rb
|
134
134
|
- test/test-data/valid
|
135
135
|
- test/test-data/valid/label
|
136
136
|
- test/test-data/valid/label/Atlantic_Records_1.xml
|
@@ -138,11 +138,11 @@ files:
|
|
138
138
|
- test/test-data/valid/label/Atlantic_Records_3.xml
|
139
139
|
- test/test-data/valid/label/search_result_1.xml
|
140
140
|
- test/test-data/valid/release
|
141
|
+
- test/test-data/valid/release/Mission_Impossible_2.xml
|
141
142
|
- test/test-data/valid/release/Under_the_Pink_3.xml
|
142
143
|
- test/test-data/valid/release/search_result_1.xml
|
143
144
|
- test/test-data/valid/release/Highway_61_Revisited_1.xml
|
144
145
|
- test/test-data/valid/release/Highway_61_Revisited_2.xml
|
145
|
-
- test/test-data/valid/release/Mission_Impossible_2.xml
|
146
146
|
- test/test-data/valid/release/Little_Earthquakes_1.xml
|
147
147
|
- test/test-data/valid/release/Little_Earthquakes_2.xml
|
148
148
|
- test/test-data/valid/release/Under_the_Pink_1.xml
|
@@ -156,17 +156,18 @@ files:
|
|
156
156
|
- test/test-data/valid/track/Silent_All_These_Years_5.xml
|
157
157
|
- test/test-data/valid/track/Silent_All_These_Years_6.xml
|
158
158
|
- test/test-data/valid/artist
|
159
|
-
- test/test-data/valid/artist/Tori_Amos_5.xml
|
160
159
|
- test/test-data/valid/artist/search_result_1.xml
|
161
|
-
- test/test-data/valid/artist/
|
160
|
+
- test/test-data/valid/artist/Tori_Amos_5.xml
|
162
161
|
- test/test-data/valid/artist/Tchaikovsky-1.xml
|
163
|
-
- test/test-data/valid/artist/
|
162
|
+
- test/test-data/valid/artist/Tori_Amos_1.xml
|
164
163
|
- test/test-data/valid/artist/Tchaikovsky-2.xml
|
164
|
+
- test/test-data/valid/artist/Tori_Amos_2.xml
|
165
165
|
- test/test-data/valid/artist/Tori_Amos_3.xml
|
166
166
|
- test/test-data/valid/artist/empty_1.xml
|
167
167
|
- test/test-data/valid/artist/Tori_Amos_4.xml
|
168
168
|
- test/test-data/valid/artist/empty_2.xml
|
169
169
|
- test/test-data/valid/release-group
|
170
|
+
- test/test-data/valid/release-group/search_result_1.xml
|
170
171
|
- test/test-data/valid/release-group/The_Cure_1.xml
|
171
172
|
- test/test-data/valid/user
|
172
173
|
- test/test-data/valid/user/User_1.xml
|
@@ -174,11 +175,11 @@ files:
|
|
174
175
|
- test/test-data/invalid/release
|
175
176
|
- test/test-data/invalid/track
|
176
177
|
- test/test-data/invalid/artist
|
178
|
+
- test/test-data/invalid/artist/ratings_1.xml
|
177
179
|
- test/test-data/invalid/artist/empty_3.xml
|
178
180
|
- test/test-data/invalid/artist/basic_1.xml
|
179
181
|
- test/test-data/invalid/artist/basic_2.xml
|
180
182
|
- test/test-data/invalid/artist/search_result_1.xml
|
181
|
-
- test/test-data/invalid/artist/ratings_1.xml
|
182
183
|
- test/test-data/invalid/artist/ratings_2.xml
|
183
184
|
- test/test-data/invalid/artist/empty_1.xml
|
184
185
|
- test/test-data/invalid/artist/tags_1.xml
|