rbrainz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +25 -0
- data/README +11 -0
- data/Rakefile +110 -0
- data/TODO +24 -0
- data/doc/README.rdoc +68 -0
- data/examples/getartist.rb +54 -0
- data/lib/rbrainz.rb +11 -0
- data/lib/rbrainz/data/countrynames.rb +259 -0
- data/lib/rbrainz/data/languagenames.rb +404 -0
- data/lib/rbrainz/data/scriptnames.rb +64 -0
- data/lib/rbrainz/model.rb +48 -0
- data/lib/rbrainz/model/alias.rb +23 -0
- data/lib/rbrainz/model/artist.rb +54 -0
- data/lib/rbrainz/model/disc.rb +30 -0
- data/lib/rbrainz/model/entity.rb +72 -0
- data/lib/rbrainz/model/incomplete_date.rb +76 -0
- data/lib/rbrainz/model/label.rb +55 -0
- data/lib/rbrainz/model/mbid.rb +82 -0
- data/lib/rbrainz/model/release.rb +50 -0
- data/lib/rbrainz/model/release_event.rb +34 -0
- data/lib/rbrainz/model/track.rb +27 -0
- data/lib/rbrainz/webservice.rb +6 -0
- data/lib/rbrainz/webservice/filter.rb +132 -0
- data/lib/rbrainz/webservice/includes.rb +150 -0
- data/lib/rbrainz/webservice/mbxml.rb +404 -0
- data/lib/rbrainz/webservice/query.rb +61 -0
- data/lib/rbrainz/webservice/webservice.rb +69 -0
- data/test/lib/test_entity.rb +58 -0
- data/test/lib/testing_helper.rb +13 -0
- data/test/test-data/README +13 -0
- data/test/test-data/invalid/artist/basic_1.xml +12 -0
- data/test/test-data/invalid/artist/basic_2.xml +12 -0
- data/test/test-data/invalid/artist/empty_1.xml +0 -0
- data/test/test-data/invalid/artist/empty_2.xml +3 -0
- data/test/test-data/invalid/artist/empty_3.xml +7 -0
- data/test/test-data/invalid/artist/search_result_1.xml +11 -0
- data/test/test-data/valid/artist/Tchaikovsky-1.xml +90 -0
- data/test/test-data/valid/artist/Tori_Amos_1.xml +8 -0
- data/test/test-data/valid/artist/Tori_Amos_2.xml +53 -0
- data/test/test-data/valid/artist/Tori_Amos_3.xml +25 -0
- data/test/test-data/valid/artist/Tori_Amos_4.xml +14 -0
- data/test/test-data/valid/artist/Tori_Amos_5.xml +13 -0
- data/test/test-data/valid/artist/empty_1.xml +7 -0
- data/test/test-data/valid/artist/empty_2.xml +11 -0
- data/test/test-data/valid/artist/search_result_1.xml +19 -0
- data/test/test-data/valid/label/Atlantic_Records_1.xml +9 -0
- data/test/test-data/valid/label/Atlantic_Records_2.xml +11 -0
- data/test/test-data/valid/label/search_result_1.xml +14 -0
- data/test/test-data/valid/release/Highway_61_Revisited_1.xml +68 -0
- data/test/test-data/valid/release/Little_Earthquakes_1.xml +24 -0
- data/test/test-data/valid/release/Little_Earthquakes_2.xml +73 -0
- data/test/test-data/valid/release/Mission_Impossible_2.xml +155 -0
- data/test/test-data/valid/release/Under_the_Pink_1.xml +16 -0
- data/test/test-data/valid/release/Under_the_Pink_2.xml +14 -0
- data/test/test-data/valid/release/Under_the_Pink_3.xml +16 -0
- data/test/test-data/valid/release/search_result_1.xml +29 -0
- data/test/test-data/valid/track/Silent_All_These_Years_1.xml +7 -0
- data/test/test-data/valid/track/Silent_All_These_Years_2.xml +21 -0
- data/test/test-data/valid/track/Silent_All_These_Years_3.xml +16 -0
- data/test/test-data/valid/track/Silent_All_These_Years_4.xml +30 -0
- data/test/test-data/valid/track/Silent_All_These_Years_5.xml +20 -0
- data/test/test-data/valid/track/search_result_1.xml +45 -0
- data/test/test-data/valid/user/User_1.xml +15 -0
- data/test/test_alias.rb +50 -0
- data/test/test_artist.rb +132 -0
- data/test/test_artist_filter.rb +36 -0
- data/test/test_artist_includes.rb +63 -0
- data/test/test_disc.rb +38 -0
- data/test/test_incomplete_date.rb +60 -0
- data/test/test_label.rb +129 -0
- data/test/test_label_filter.rb +36 -0
- data/test/test_label_includes.rb +55 -0
- data/test/test_mbid.rb +99 -0
- data/test/test_mbxml.rb +368 -0
- data/test/test_query.rb +24 -0
- data/test/test_release.rb +161 -0
- data/test/test_release_event.rb +67 -0
- data/test/test_release_filter.rb +57 -0
- data/test/test_release_includes.rb +73 -0
- data/test/test_track.rb +102 -0
- data/test/test_track_filter.rb +57 -0
- data/test/test_track_includes.rb +61 -0
- data/test/test_webservice.rb +23 -0
- metadata +138 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#">
|
3
|
+
<release id="290e10c5-7efc-4f60-ba2c-0dfc0208fbf5" type="Album Official">
|
4
|
+
<title>Under the Pink</title>
|
5
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
6
|
+
<name>Tori Amos</name>
|
7
|
+
</artist>
|
8
|
+
<track-list offset="1" count="12">
|
9
|
+
<track id="0a984e3b-e38a-4b86-80be-f3a3eb1114ca">
|
10
|
+
<title>God</title>
|
11
|
+
</track>
|
12
|
+
</track-list>
|
13
|
+
</release>
|
14
|
+
</metadata>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#">
|
3
|
+
<release id="290e10c5-7efc-4f60-ba2c-0dfc0208fbf5" type="Album Official">
|
4
|
+
<title>Under the Pink</title>
|
5
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
6
|
+
<name>Tori Amos</name>
|
7
|
+
</artist>
|
8
|
+
<release-event-list>
|
9
|
+
<event date="1994-01-31" catalog-number="82567-2" barcode="07567825672">
|
10
|
+
<label id="50c384a2-0b44-401b-b893-8181173339c7">
|
11
|
+
<name>Atlantic Records</name>
|
12
|
+
</label>
|
13
|
+
</event>
|
14
|
+
</release-event-list>
|
15
|
+
</release>
|
16
|
+
</metadata>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"
|
4
|
+
xmlns:ext="http://musicbrainz.org/ns/ext-1.0#">
|
5
|
+
|
6
|
+
<release-list offset="0" count="234">
|
7
|
+
<release id="290e10c5-7efc-4f60-ba2c-0dfc0208fbf5" type="Album Official" ext:score="100">
|
8
|
+
<title>Under the Pink</title>
|
9
|
+
<text-representation language="ENG" script="Latn"/>
|
10
|
+
<asin>B000002IXU</asin>
|
11
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
12
|
+
<name>Tori Amos</name>
|
13
|
+
</artist>
|
14
|
+
<release-event-list>
|
15
|
+
<event date="1994-01-28"/>
|
16
|
+
</release-event-list>
|
17
|
+
<disc-list count="4"/>
|
18
|
+
<track-list count="12"/>
|
19
|
+
</release>
|
20
|
+
<release id="005fe18b-144b-4fee-81c0-e04737a23500" type="Live Bootleg" ext:score="80">
|
21
|
+
<title>Under the Pink Tour 1994</title>
|
22
|
+
<text-representation language="ENG" script="Latn"/>
|
23
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
24
|
+
<name>Tori Amos</name>
|
25
|
+
</artist>
|
26
|
+
<track-list count="17"/>
|
27
|
+
</release>
|
28
|
+
</release-list>
|
29
|
+
</metadata>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#">
|
3
|
+
<track id="d6118046-407d-4e06-a1ba-49c399a4c42f">
|
4
|
+
<title>Silent All These Years</title>
|
5
|
+
<duration>253466</duration>
|
6
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5" type="Person">
|
7
|
+
<name>Tori Amos</name>
|
8
|
+
<sort-name>Amos, Tori</sort-name>
|
9
|
+
</artist>
|
10
|
+
<relation-list target-type="Track">
|
11
|
+
<relation type="Cover"
|
12
|
+
direction="backward"
|
13
|
+
target="31e1c0c4-967f-435e-b09a-35ee079ee234">
|
14
|
+
<track id="31e1c0c4-967f-435e-b09a-35ee079ee234">
|
15
|
+
<title>Silent All These Years</title>
|
16
|
+
<artist id="5bcd4eaa-fae7-465f-9f03-d005b959ed02"/>
|
17
|
+
</track>
|
18
|
+
</relation>
|
19
|
+
</relation-list>
|
20
|
+
</track>
|
21
|
+
</metadata>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#">
|
3
|
+
<track id="d6118046-407d-4e06-a1ba-49c399a4c42f">
|
4
|
+
<title>Silent All These Years</title>
|
5
|
+
<duration>253466</duration>
|
6
|
+
<puid-list>
|
7
|
+
<puid id="c2a2cee5-a8ca-4f89-a092-c3e1e65ab7e6"/>
|
8
|
+
<puid id="db5b66b3-fa97-4cfa-9296-de7e57ef05f4"/>
|
9
|
+
<puid id="fbb3d1b6-f9e7-49ed-834c-03e9ec9726e5"/>
|
10
|
+
<puid id="0e2e66e3-13d7-4138-af90-5ec8a4c2db99"/>
|
11
|
+
<puid id="4778d58b-50fe-4004-8cd6-462a816114c8"/>
|
12
|
+
<puid id="88541d46-9b74-4835-b8e8-d985fc77e02a"/>
|
13
|
+
<puid id="42ab76ea-5d42-4259-85d7-e7f2c69e4485"/>
|
14
|
+
</puid-list>
|
15
|
+
</track>
|
16
|
+
</metadata>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"
|
3
|
+
xmlns:mm="http://mafr.de/ns/mm-0.1#">
|
4
|
+
|
5
|
+
<track id="d6118046-407d-4e06-a1ba-49c399a4c42f">
|
6
|
+
<title>Silent All These Years</title>
|
7
|
+
<duration>253466</duration>
|
8
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5" type="Person">
|
9
|
+
<name>Tori Amos</name>
|
10
|
+
<sort-name>Amos, Tori</sort-name>
|
11
|
+
<life-span begin="1963-08-22"/>
|
12
|
+
</artist>
|
13
|
+
<release-list>
|
14
|
+
<release id="02232360-337e-4a3f-ad20-6cdd4c34288c" type="Album Official">
|
15
|
+
<title>Little Earthquakes</title>
|
16
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5" type="Person"/>
|
17
|
+
<track-list offset="2"/>
|
18
|
+
</release>
|
19
|
+
</release-list>
|
20
|
+
<puid-list>
|
21
|
+
<puid id="c2a2cee5-a8ca-4f89-a092-c3e1e65ab7e6"/>
|
22
|
+
<puid id="db5b66b3-fa97-4cfa-9296-de7e57ef05f4"/>
|
23
|
+
<puid id="fbb3d1b6-f9e7-49ed-834c-03e9ec9726e5"/>
|
24
|
+
<puid id="0e2e66e3-13d7-4138-af90-5ec8a4c2db99"/>
|
25
|
+
<puid id="4778d58b-50fe-4004-8cd6-462a816114c8"/>
|
26
|
+
<puid id="88541d46-9b74-4835-b8e8-d985fc77e02a"/>
|
27
|
+
<puid id="42ab76ea-5d42-4259-85d7-e7f2c69e4485"/>
|
28
|
+
</puid-list>
|
29
|
+
</track>
|
30
|
+
</metadata>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"
|
3
|
+
xmlns:mm="http://mafr.de/ns/mm-0.1#">
|
4
|
+
|
5
|
+
<track id="d6118046-407d-4e06-a1ba-49c399a4c42f">
|
6
|
+
<title>Silent All These Years</title>
|
7
|
+
<duration>253466</duration>
|
8
|
+
<puid-list>
|
9
|
+
<puid id="c2a2cee5-a8ca-4f89-a092-c3e1e65ab7e6"/>
|
10
|
+
<puid id="db5b66b3-fa97-4cfa-9296-de7e57ef05f4"/>
|
11
|
+
<puid id="fbb3d1b6-f9e7-49ed-834c-03e9ec9726e5"/>
|
12
|
+
<puid id="0e2e66e3-13d7-4138-af90-5ec8a4c2db99"/>
|
13
|
+
<puid id="4778d58b-50fe-4004-8cd6-462a816114c8"/>
|
14
|
+
<puid id="88541d46-9b74-4835-b8e8-d985fc77e02a"/>
|
15
|
+
<puid id="42ab76ea-5d42-4259-85d7-e7f2c69e4485"/>
|
16
|
+
</puid-list>
|
17
|
+
<mm:rating value="9"/>
|
18
|
+
<mm:annotation>This is a <em>very</em> nice song.</mm:annotation>
|
19
|
+
</track>
|
20
|
+
</metadata>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"
|
3
|
+
xmlns:ext="http://musicbrainz.org/ns/ext-1.0#">
|
4
|
+
<track-list count="100" offset="7">
|
5
|
+
<track id="748f2b79-8c50-4581-adb1-7708118a48fc" ext:score="100">
|
6
|
+
<title>Little Earthquakes</title>
|
7
|
+
<duration>457760</duration>
|
8
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
9
|
+
<name>Tori Amos</name>
|
10
|
+
</artist>
|
11
|
+
<release-list>
|
12
|
+
<release id="93264fe5-dff2-47ab-9ca8-1c865733aad9">
|
13
|
+
<title>To Venus and Back (disc 2: Live, Still Orbiting)</title>
|
14
|
+
<track-list offset="9"/>
|
15
|
+
</release>
|
16
|
+
</release-list>
|
17
|
+
</track>
|
18
|
+
<track id="51d2c2ff-a5fd-44f9-9c1c-7ca9fdc7dd1d" ext:score="99">
|
19
|
+
<title>Little Earthquakes</title>
|
20
|
+
<duration>413693</duration>
|
21
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
22
|
+
<name>Tori Amos</name>
|
23
|
+
</artist>
|
24
|
+
<release-list>
|
25
|
+
<release id="02232360-337e-4a3f-ad20-6cdd4c34288c">
|
26
|
+
<title>Little Earthquakes</title>
|
27
|
+
<track-list offset="11"/>
|
28
|
+
</release>
|
29
|
+
</release-list>
|
30
|
+
</track>
|
31
|
+
<track id="1954d2a1-d021-4426-b818-b5a5bce1ca07" ext:score="80">
|
32
|
+
<title>Little Amsterdam</title>
|
33
|
+
<duration>270106</duration>
|
34
|
+
<artist id="c0b2500e-0cef-4130-869d-732b23ed9df5">
|
35
|
+
<name>Tori Amos</name>
|
36
|
+
</artist>
|
37
|
+
<release-list>
|
38
|
+
<release id="4c31aef1-177e-4bba-9a56-180e21a0d043">
|
39
|
+
<title>Boys for Pele</title>
|
40
|
+
<track-list offset="11"/>
|
41
|
+
</release>
|
42
|
+
</release-list>
|
43
|
+
</track>
|
44
|
+
</track-list>
|
45
|
+
</metadata>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<!-- Note: This is a MusicBrainz extension. -->
|
4
|
+
|
5
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"
|
6
|
+
xmlns:ext="http://musicbrainz.org/ns/ext-1.0#">
|
7
|
+
|
8
|
+
<ext:user-list>
|
9
|
+
<ext:user type="AutoEditor RelationshipEditor">
|
10
|
+
<name>matt</name>
|
11
|
+
<ext:nag show="false"/>
|
12
|
+
</ext:user>
|
13
|
+
</ext:user-list>
|
14
|
+
|
15
|
+
</metadata>
|
data/test/test_alias.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# $Id$
|
2
|
+
# Copyright (c) 2007, Philipp Wolfer
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE for permissions.
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'rbrainz/model'
|
8
|
+
include MusicBrainz
|
9
|
+
|
10
|
+
# Unit test for the Alias model.
|
11
|
+
class TestAlias < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_new_alias
|
20
|
+
assert_nothing_raised {Model::Alias.new}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_name
|
24
|
+
alias_ = Model::Alias.new
|
25
|
+
alias_.name = 'Dark Tranquility'
|
26
|
+
assert_equal 'Dark Tranquility', alias_.name
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_type
|
30
|
+
alias_ = Model::Alias.new
|
31
|
+
alias_.type = 'Misspelling'
|
32
|
+
assert_equal 'Misspelling', alias_.type
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_script
|
36
|
+
alias_ = Model::Alias.new
|
37
|
+
alias_.script = 'Latn'
|
38
|
+
assert_equal 'Latn', alias_.script
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_to_string
|
42
|
+
alias_ = Model::Alias.new
|
43
|
+
assert_equal '', alias_.to_s
|
44
|
+
alias_.name = 'Dark Tranquility'
|
45
|
+
alias_.type = 'Misspelling'
|
46
|
+
alias_.script = 'Latn'
|
47
|
+
assert_equal 'Dark Tranquility', alias_.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/test_artist.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# $Id$
|
2
|
+
# Copyright (c) 2007, Philipp Wolfer
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE for permissions.
|
5
|
+
|
6
|
+
require 'test_entity'
|
7
|
+
|
8
|
+
# Unit test for the Artist model.
|
9
|
+
class TestArtist < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@tested_class = Model::Artist
|
13
|
+
@invalid_entity_types = [:release, :track, :label]
|
14
|
+
@releases = [Model::Release.new, Model::Release.new]
|
15
|
+
@aliases = [Model::Alias.new, Model::Alias.new]
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
end
|
20
|
+
|
21
|
+
# Include the tests for Entity
|
22
|
+
include TestEntity
|
23
|
+
|
24
|
+
def test_new_artist
|
25
|
+
artist = nil
|
26
|
+
assert_nothing_raised {artist = Model::Artist.new}
|
27
|
+
assert artist.is_a?(Model::Entity)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_name
|
31
|
+
artist = Model::Artist.new
|
32
|
+
assert artist.name.nil?
|
33
|
+
assert_nothing_raised {artist.name = 'Paradise Lost'}
|
34
|
+
assert_equal 'Paradise Lost', artist.name
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_sort_name
|
38
|
+
artist = Model::Artist.new
|
39
|
+
assert artist.sort_name.nil?
|
40
|
+
assert_nothing_raised {artist.sort_name = 'Paradise Lost'}
|
41
|
+
assert_equal 'Paradise Lost', artist.sort_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_disambiguation
|
45
|
+
artist = Model::Artist.new
|
46
|
+
assert artist.disambiguation.nil?
|
47
|
+
assert_nothing_raised {artist.disambiguation = 'Disambiguation comment'}
|
48
|
+
assert_equal 'Disambiguation comment', artist.disambiguation
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_type
|
52
|
+
artist = Model::Artist.new
|
53
|
+
assert artist.type.nil?
|
54
|
+
assert_nothing_raised {artist.type = Model::Artist::TYPE_PERSON}
|
55
|
+
assert_equal Model::Artist::TYPE_PERSON, artist.type
|
56
|
+
assert_nothing_raised {artist.type = Model::Artist::TYPE_GROUP}
|
57
|
+
assert_equal Model::Artist::TYPE_GROUP, artist.type
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_begin_date
|
61
|
+
artist = Model::Artist.new
|
62
|
+
date = Model::IncompleteDate.new '1988-04-18'
|
63
|
+
assert_nothing_raised {artist.begin_date}
|
64
|
+
assert_equal nil, artist.begin_date
|
65
|
+
assert_nothing_raised {artist.begin_date = date}
|
66
|
+
assert_equal date, artist.begin_date
|
67
|
+
|
68
|
+
# It should be able to supply a date as a string,
|
69
|
+
# but Artist should convert it to an IncompleteDate.
|
70
|
+
assert_nothing_raised {artist.begin_date = '1988-04-20'}
|
71
|
+
assert_equal Model::IncompleteDate.new('1988-04-20'), artist.begin_date
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_end_date
|
75
|
+
artist = Model::Artist.new
|
76
|
+
date = Model::IncompleteDate.new '1988-04-18'
|
77
|
+
assert_nothing_raised {artist.end_date}
|
78
|
+
assert_equal nil, artist.end_date
|
79
|
+
assert_nothing_raised {artist.end_date = date}
|
80
|
+
assert_equal date, artist.end_date
|
81
|
+
|
82
|
+
# It should be able to supply a date as a string,
|
83
|
+
# but Artist should convert it to an IncompleteDate.
|
84
|
+
assert_nothing_raised {artist.end_date = '1988-04-20'}
|
85
|
+
assert_equal Model::IncompleteDate.new('1988-04-20'), artist.end_date
|
86
|
+
end
|
87
|
+
|
88
|
+
# Many releases can be added
|
89
|
+
def test_add_and_remove_releases
|
90
|
+
artist = Model::Artist.new
|
91
|
+
assert_equal 0, artist.releases.size
|
92
|
+
assert_nothing_raised {artist.releases << @releases[0]}
|
93
|
+
assert_equal 1, artist.releases.size
|
94
|
+
assert_nothing_raised {artist.releases << @releases[1]}
|
95
|
+
assert_equal 2, artist.releases.size
|
96
|
+
|
97
|
+
assert_nothing_raised {artist.releases.delete @releases[1]}
|
98
|
+
assert_equal 1, artist.releases.size
|
99
|
+
assert_nothing_raised {artist.releases.delete @releases[0]}
|
100
|
+
assert_equal 0, artist.releases.size
|
101
|
+
end
|
102
|
+
|
103
|
+
# You can pass an array of releases to add them all.
|
104
|
+
def test_add_several_releases_at_once
|
105
|
+
artist = Model::Artist.new
|
106
|
+
assert_nothing_raised {artist.releases = @releases}
|
107
|
+
assert_equal @releases, artist.releases
|
108
|
+
end
|
109
|
+
|
110
|
+
# Many aliases can be added
|
111
|
+
def test_add_and_remove_aliases
|
112
|
+
artist = Model::Artist.new
|
113
|
+
assert_equal 0, artist.aliases.size
|
114
|
+
assert_nothing_raised {artist.aliases << @aliases[0]}
|
115
|
+
assert_equal 1, artist.aliases.size
|
116
|
+
assert_nothing_raised {artist.aliases << @aliases[1]}
|
117
|
+
assert_equal 2, artist.aliases.size
|
118
|
+
|
119
|
+
assert_nothing_raised {artist.aliases.delete @aliases[1]}
|
120
|
+
assert_equal 1, artist.aliases.size
|
121
|
+
assert_nothing_raised {artist.aliases.delete @aliases[0]}
|
122
|
+
assert_equal 0, artist.aliases.size
|
123
|
+
end
|
124
|
+
|
125
|
+
# You can pass an array of aliases to add them all.
|
126
|
+
def test_add_several_aliases_at_once
|
127
|
+
artist = Model::Artist.new
|
128
|
+
assert_nothing_raised {artist.aliases = @aliases}
|
129
|
+
assert_equal @aliases, artist.aliases
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# $Id$
|
2
|
+
# Copyright (c) 2007, Philipp Wolfer
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE for permissions.
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'testing_helper'
|
8
|
+
require 'rbrainz'
|
9
|
+
include MusicBrainz
|
10
|
+
|
11
|
+
# Unit test for the ArtistFilter class.
|
12
|
+
class TestArtistFilter < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@filter_hash = {:name => 'Tori Amos', :limit => 10}
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_filter
|
22
|
+
filter = Webservice::ArtistFilter.new(@filter_hash)
|
23
|
+
filter_string = filter.to_s
|
24
|
+
assert_not_equal '&', filter_string[0]
|
25
|
+
|
26
|
+
result_hash = query_string_to_hash filter_string
|
27
|
+
assert_equal @filter_hash[:name], result_hash['name'], filter_string
|
28
|
+
assert_equal @filter_hash[:limit].to_s, result_hash['limit'], filter_string
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_empty_filter
|
32
|
+
filter = Webservice::ArtistFilter.new({})
|
33
|
+
assert_equal '', filter.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|