7digital 0.1.2 → 0.1.5
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.
- checksums.yaml +7 -0
- data/README.rdoc +143 -143
- data/lib/sevendigital.rb +55 -55
- data/lib/sevendigital/api_operator.rb +127 -127
- data/lib/sevendigital/api_operator_cached.rb +91 -62
- data/lib/sevendigital/api_request.rb +72 -62
- data/lib/sevendigital/client.rb +122 -122
- data/lib/sevendigital/client_configuration.rb +85 -83
- data/lib/sevendigital/client_digestors.rb +122 -122
- data/lib/sevendigital/client_managers.rb +57 -57
- data/lib/sevendigital/digestion_tract/api_response_digestor.rb +48 -48
- data/lib/sevendigital/digestion_tract/artist_digestor.rb +35 -35
- data/lib/sevendigital/digestion_tract/basket_digestor.rb +19 -19
- data/lib/sevendigital/digestion_tract/basket_item_digestor.rb +26 -26
- data/lib/sevendigital/digestion_tract/chart_item_digestor.rb +34 -34
- data/lib/sevendigital/digestion_tract/country_digestor.rb +15 -15
- data/lib/sevendigital/digestion_tract/digestor.rb +122 -122
- data/lib/sevendigital/digestion_tract/download_url_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/format_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/label_digestor.rb +21 -21
- data/lib/sevendigital/digestion_tract/list_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/list_item_digestor.rb +26 -26
- data/lib/sevendigital/digestion_tract/locker_digestor.rb +22 -22
- data/lib/sevendigital/digestion_tract/locker_release_digestor.rb +26 -26
- data/lib/sevendigital/digestion_tract/locker_track_digestor.rb +26 -26
- data/lib/sevendigital/digestion_tract/oauth_access_token_digestor.rb +18 -18
- data/lib/sevendigital/digestion_tract/oauth_request_token_digestor.rb +18 -18
- data/lib/sevendigital/digestion_tract/pager_digestor.rb +28 -28
- data/lib/sevendigital/digestion_tract/price_digestor.rb +28 -28
- data/lib/sevendigital/digestion_tract/release_digestor.rb +45 -45
- data/lib/sevendigital/digestion_tract/tag_digestor.rb +23 -23
- data/lib/sevendigital/digestion_tract/track_digestor.rb +38 -37
- data/lib/sevendigital/digestion_tract/user_card_digestor.rb +24 -24
- data/lib/sevendigital/digestion_tract/user_digestor.rb +21 -21
- data/lib/sevendigital/management/artist_manager.rb +97 -97
- data/lib/sevendigital/management/basket_manager.rb +29 -29
- data/lib/sevendigital/management/country_manager.rb +10 -10
- data/lib/sevendigital/management/list_manager.rb +18 -18
- data/lib/sevendigital/management/manager.rb +12 -12
- data/lib/sevendigital/management/oauth_manager.rb +23 -23
- data/lib/sevendigital/management/release_manager.rb +54 -54
- data/lib/sevendigital/management/tag_manager.rb +10 -10
- data/lib/sevendigital/management/track_manager.rb +29 -27
- data/lib/sevendigital/management/user_card_manager.rb +26 -26
- data/lib/sevendigital/management/user_manager.rb +76 -76
- data/lib/sevendigital/model/api_response.rb +32 -32
- data/lib/sevendigital/model/artist.rb +104 -104
- data/lib/sevendigital/model/basket.rb +15 -15
- data/lib/sevendigital/model/basket_item.rb +14 -14
- data/lib/sevendigital/model/card.rb +11 -11
- data/lib/sevendigital/model/chart_item.rb +9 -9
- data/lib/sevendigital/model/download_url.rb +7 -7
- data/lib/sevendigital/model/format.rb +7 -7
- data/lib/sevendigital/model/label.rb +7 -7
- data/lib/sevendigital/model/list.rb +4 -4
- data/lib/sevendigital/model/list_item.rb +8 -8
- data/lib/sevendigital/model/locker.rb +4 -4
- data/lib/sevendigital/model/locker_release.rb +9 -9
- data/lib/sevendigital/model/locker_track.rb +9 -9
- data/lib/sevendigital/model/price.rb +9 -9
- data/lib/sevendigital/model/release.rb +57 -57
- data/lib/sevendigital/model/sevendigital_error.rb +11 -11
- data/lib/sevendigital/model/sevendigital_object.rb +57 -57
- data/lib/sevendigital/model/tag.rb +7 -7
- data/lib/sevendigital/model/track.rb +87 -83
- data/lib/sevendigital/model/user.rb +74 -74
- data/lib/sevendigital/pager.rb +20 -20
- data/lib/sevendigital/version.rb +5 -5
- data/spec/api_operator_cached_spec.rb +233 -178
- data/spec/api_operator_spec.rb +320 -320
- data/spec/api_request_spec.rb +46 -31
- data/spec/client_configuration_spec.rb +78 -78
- data/spec/client_spec.rb +161 -161
- data/spec/data/config/sevendigital.yml +5 -5
- data/spec/data/configuration_env_override.yml +5 -5
- data/spec/data/configuration_override.yml +1 -1
- data/spec/digestion_tract/api_response_digestor_spec.rb +93 -93
- data/spec/digestion_tract/artist_digestor_spec.rb +81 -81
- data/spec/digestion_tract/basket_digestor_spec.rb +31 -31
- data/spec/digestion_tract/basket_item_digestor_spec.rb +58 -58
- data/spec/digestion_tract/chart_digestor_spec.rb +52 -52
- data/spec/digestion_tract/country_digestor_spec.rb +33 -33
- data/spec/digestion_tract/digestor_spec.rb +33 -33
- data/spec/digestion_tract/download_url_digestor_spec.rb +40 -40
- data/spec/digestion_tract/format_digestor_spec.rb +38 -38
- data/spec/digestion_tract/label_digestor_spec.rb +33 -33
- data/spec/digestion_tract/list_digestor_spec.rb +31 -31
- data/spec/digestion_tract/list_item_digestor_spec.rb +80 -80
- data/spec/digestion_tract/locker_digestor_spec.rb +30 -30
- data/spec/digestion_tract/locker_release_digestor_spec.rb +70 -70
- data/spec/digestion_tract/locker_track_digestor_spec.rb +56 -56
- data/spec/digestion_tract/oauth_access_token_digestor_spec.rb +34 -34
- data/spec/digestion_tract/oauth_request_token_digestor_spec.rb +34 -34
- data/spec/digestion_tract/pager_digestor_spec.rb +50 -50
- data/spec/digestion_tract/price_digestor_spec.rb +73 -73
- data/spec/digestion_tract/release_digestor_spec.rb +115 -115
- data/spec/digestion_tract/tag_digestor_spec.rb +46 -46
- data/spec/digestion_tract/track_digestor_spec.rb +105 -104
- data/spec/digestion_tract/user_card_digestor_spec.rb +58 -58
- data/spec/digestion_tract/user_digestor_spec.rb +42 -42
- data/spec/integration/artist_spec.rb +99 -86
- data/spec/integration/country_spec.rb +18 -18
- data/spec/integration/list_spec.rb +22 -22
- data/spec/integration/purchasing_spec.rb +24 -24
- data/spec/integration/release_spec.rb +34 -34
- data/spec/integration/sevendigital_spec.yml +4 -4
- data/spec/integration/track_spec.rb +38 -23
- data/spec/integration/user_spec.rb +22 -22
- data/spec/management/artist_manager_spec.rb +172 -172
- data/spec/management/basket_manager_spec.rb +77 -77
- data/spec/management/country_manager_spec.rb +34 -34
- data/spec/management/list_manager_spec.rb +26 -26
- data/spec/management/oauth_manager_spec.rb +72 -72
- data/spec/management/release_manager_spec.rb +200 -200
- data/spec/management/tag_manager_spec.rb +34 -34
- data/spec/management/track_manager_spec.rb +111 -107
- data/spec/management/user_card_manager_spec.rb +78 -78
- data/spec/management/user_manager_spec.rb +218 -218
- data/spec/model/api_response_spec.rb +48 -48
- data/spec/model/artist_spec.rb +162 -162
- data/spec/model/basket_spec.rb +62 -62
- data/spec/model/release_spec.rb +133 -133
- data/spec/model/sevendigital_object_spec.rb +73 -73
- data/spec/model/track_spec.rb +146 -144
- data/spec/model/user_spec.rb +181 -181
- data/spec/spec_helper.rb +86 -84
- data/spec/test-xml/methods/artist/browse.xml +21 -21
- data/spec/test-xml/methods/artist/byTag/top.xml +50 -50
- data/spec/test-xml/methods/artist/chart.xml +30 -30
- data/spec/test-xml/methods/artist/details.xml +9 -9
- data/spec/test-xml/methods/artist/releases.xml +544 -544
- data/spec/test-xml/methods/artist/search.xml +18 -18
- data/spec/test-xml/methods/artist/similar.xml +39 -39
- data/spec/test-xml/methods/artist/tags.xml +11 -11
- data/spec/test-xml/methods/artist/toptracks.xml +279 -279
- data/spec/test-xml/methods/basket/additem.xml +23 -23
- data/spec/test-xml/methods/basket/create.xml +10 -10
- data/spec/test-xml/methods/basket/index.xml +23 -23
- data/spec/test-xml/methods/basket/removeitem.xml +10 -10
- data/spec/test-xml/methods/country/resolve.xml +6 -6
- data/spec/test-xml/methods/editorial/list.xml +170 -170
- data/spec/test-xml/methods/oauth/accesstoken.xml +5 -5
- data/spec/test-xml/methods/oauth/requesttoken.xml +5 -5
- data/spec/test-xml/methods/release/bydate.xml +173 -173
- data/spec/test-xml/methods/release/bytag/top.xml +150 -150
- data/spec/test-xml/methods/release/chart.xml +181 -181
- data/spec/test-xml/methods/release/details.xml +48 -48
- data/spec/test-xml/methods/release/recommend.xml +89 -89
- data/spec/test-xml/methods/release/search.xml +194 -194
- data/spec/test-xml/methods/release/tags.xml +27 -27
- data/spec/test-xml/methods/release/tracks.xml +28 -28
- data/spec/test-xml/methods/tag/index.xml +16 -16
- data/spec/test-xml/methods/track/chart.xml +149 -149
- data/spec/test-xml/methods/track/details.xml +30 -30
- data/spec/test-xml/methods/track/search.xml +159 -159
- data/spec/test-xml/methods/user/details.xml +4 -4
- data/spec/test-xml/methods/user/locker.xml +49 -49
- data/spec/test-xml/methods/user/payment/card/add.xml +7 -7
- data/spec/test-xml/methods/user/payment/card/index.xml +7 -7
- data/spec/test-xml/methods/user/purchase/basket.xml +48 -48
- data/spec/test-xml/methods/user/purchase/item.xml +48 -48
- data/spec/test-xml/methods/user/signUp.xml +5 -5
- data/spec/test-xml/objects/artist.xml +7 -7
- data/spec/test-xml/objects/artist_chart_item.xml +7 -7
- data/spec/test-xml/objects/artist_list.xml +22 -22
- data/spec/test-xml/objects/artist_list_empty.xml +4 -4
- data/spec/test-xml/objects/basket.xml +21 -21
- data/spec/test-xml/objects/basket_item.xml +11 -11
- data/spec/test-xml/objects/basket_item_list.xml +25 -25
- data/spec/test-xml/objects/basket_item_list_empty.xml +1 -1
- data/spec/test-xml/objects/download_url.xml +7 -7
- data/spec/test-xml/objects/list.xml +89 -89
- data/spec/test-xml/objects/list_item_list.xml +85 -85
- data/spec/test-xml/objects/list_item_release.xml +13 -13
- data/spec/test-xml/objects/locker.xml +47 -47
- data/spec/test-xml/objects/locker_release.xml +40 -40
- data/spec/test-xml/objects/locker_release_list.xml +87 -87
- data/spec/test-xml/objects/locker_release_list_empty.xml +4 -4
- data/spec/test-xml/objects/locker_release_one_item_list.xml +43 -43
- data/spec/test-xml/objects/locker_track.xml +25 -25
- data/spec/test-xml/objects/locker_track_list.xml +26 -26
- data/spec/test-xml/objects/locker_track_list_empty.xml +2 -2
- data/spec/test-xml/objects/nested_release_list.xml +22 -22
- data/spec/test-xml/objects/oauth_access_token.xml +3 -3
- data/spec/test-xml/objects/oauth_request_token.xml +3 -3
- data/spec/test-xml/objects/price.xml +7 -7
- data/spec/test-xml/objects/release.xml +40 -40
- data/spec/test-xml/objects/release_chart_item.xml +39 -39
- data/spec/test-xml/objects/release_list.xml +18 -18
- data/spec/test-xml/objects/release_list_empty.xml +4 -4
- data/spec/test-xml/objects/response.xml +38 -38
- data/spec/test-xml/objects/tag.xml +4 -4
- data/spec/test-xml/objects/track.xml +34 -33
- data/spec/test-xml/objects/track_chart_item.xml +27 -27
- data/spec/test-xml/objects/user.xml +4 -4
- data/spec/test-xml/objects/user_payment_card.xml +5 -5
- metadata +15 -25
@@ -1,35 +1,35 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "OAuthAccessTokenDigestor" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@stub_oauth_consumer = stub(OAuth::Consumer)
|
7
|
-
api_client = stub(Sevendigital::Client)
|
8
|
-
api_client.stub!(:oauth_consumer).and_return(@stub_oauth_consumer)
|
9
|
-
@token_digestor = Sevendigital::OAuthAccessTokenDigestor.new(api_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
it "should not digest from invalid xml but throw up (exception)" do
|
14
|
-
|
15
|
-
xml_response = <<XML
|
16
|
-
<release id="123">
|
17
|
-
<name>expected artist name</name>
|
18
|
-
</release>
|
19
|
-
XML
|
20
|
-
|
21
|
-
running {@token_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should digest access token xml and populate all properties" do
|
25
|
-
|
26
|
-
xml_response = load_sample_object_xml("oauth_access_token")
|
27
|
-
|
28
|
-
token = @token_digestor.from_xml_string(xml_response, :oauth_access_token)
|
29
|
-
token.kind_of?(OAuth::AccessToken).should == true
|
30
|
-
token.token.should == "E3w4FV3oirRfj4KfT7alOpa893mmn4HJ"
|
31
|
-
token.secret.should == "923kj3Kspa304n4Oamd3201pLkgjeM32"
|
32
|
-
token.consumer.should == @stub_oauth_consumer
|
33
|
-
end
|
34
|
-
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "OAuthAccessTokenDigestor" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@stub_oauth_consumer = stub(OAuth::Consumer)
|
7
|
+
api_client = stub(Sevendigital::Client)
|
8
|
+
api_client.stub!(:oauth_consumer).and_return(@stub_oauth_consumer)
|
9
|
+
@token_digestor = Sevendigital::OAuthAccessTokenDigestor.new(api_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
14
|
+
|
15
|
+
xml_response = <<XML
|
16
|
+
<release id="123">
|
17
|
+
<name>expected artist name</name>
|
18
|
+
</release>
|
19
|
+
XML
|
20
|
+
|
21
|
+
running {@token_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should digest access token xml and populate all properties" do
|
25
|
+
|
26
|
+
xml_response = load_sample_object_xml("oauth_access_token")
|
27
|
+
|
28
|
+
token = @token_digestor.from_xml_string(xml_response, :oauth_access_token)
|
29
|
+
token.kind_of?(OAuth::AccessToken).should == true
|
30
|
+
token.token.should == "E3w4FV3oirRfj4KfT7alOpa893mmn4HJ"
|
31
|
+
token.secret.should == "923kj3Kspa304n4Oamd3201pLkgjeM32"
|
32
|
+
token.consumer.should == @stub_oauth_consumer
|
33
|
+
end
|
34
|
+
|
35
35
|
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "OAuthRequestTokenDigestor" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@stub_oauth_consumer = stub(OAuth::Consumer)
|
7
|
-
api_client = stub(Sevendigital::Client)
|
8
|
-
api_client.stub!(:oauth_consumer).and_return(@stub_oauth_consumer)
|
9
|
-
@token_digestor = Sevendigital::OAuthRequestTokenDigestor.new(api_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
it "should not digest from invalid xml but throw up (exception)" do
|
14
|
-
|
15
|
-
xml_response = <<XML
|
16
|
-
<release id="123">
|
17
|
-
<name>expected artist name</name>
|
18
|
-
</release>
|
19
|
-
XML
|
20
|
-
|
21
|
-
running {@token_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should digest request token xml and populate all properties" do
|
25
|
-
|
26
|
-
xml_response = load_sample_object_xml("oauth_request_token")
|
27
|
-
|
28
|
-
token = @token_digestor.from_xml_string(xml_response, :oauth_request_token)
|
29
|
-
token.kind_of?(OAuth::RequestToken).should == true
|
30
|
-
token.token.should == "yu87230J29DT7tyuGslO98wrR43e39Of"
|
31
|
-
token.secret.should == "d2I8uj7yaoa39KKdu3upasybu98f89fln"
|
32
|
-
token.consumer.should == @stub_oauth_consumer
|
33
|
-
end
|
34
|
-
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "OAuthRequestTokenDigestor" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@stub_oauth_consumer = stub(OAuth::Consumer)
|
7
|
+
api_client = stub(Sevendigital::Client)
|
8
|
+
api_client.stub!(:oauth_consumer).and_return(@stub_oauth_consumer)
|
9
|
+
@token_digestor = Sevendigital::OAuthRequestTokenDigestor.new(api_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
14
|
+
|
15
|
+
xml_response = <<XML
|
16
|
+
<release id="123">
|
17
|
+
<name>expected artist name</name>
|
18
|
+
</release>
|
19
|
+
XML
|
20
|
+
|
21
|
+
running {@token_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should digest request token xml and populate all properties" do
|
25
|
+
|
26
|
+
xml_response = load_sample_object_xml("oauth_request_token")
|
27
|
+
|
28
|
+
token = @token_digestor.from_xml_string(xml_response, :oauth_request_token)
|
29
|
+
token.kind_of?(OAuth::RequestToken).should == true
|
30
|
+
token.token.should == "yu87230J29DT7tyuGslO98wrR43e39Of"
|
31
|
+
token.secret.should == "d2I8uj7yaoa39KKdu3upasybu98f89fln"
|
32
|
+
token.consumer.should == @stub_oauth_consumer
|
33
|
+
end
|
34
|
+
|
35
35
|
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "PagerDigestor" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@pager_digestor = Sevendigital::PagerDigestor.new(nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
it "should not digest from invalid xml but throw up (exception)" do
|
11
|
-
|
12
|
-
xml_response = <<XML
|
13
|
-
<release id="123">
|
14
|
-
<name>expected artist name</name>
|
15
|
-
</release>
|
16
|
-
XML
|
17
|
-
|
18
|
-
running {@pager_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should not digest if paging info is missing from xml but spit out nil" do
|
22
|
-
|
23
|
-
xml_response = <<XML
|
24
|
-
<results id="123">
|
25
|
-
<page>3</page>
|
26
|
-
<totalItems>99</totalItems>
|
27
|
-
<pageSizeElementMissing>22</pageSizeElementMissing>
|
28
|
-
</results>
|
29
|
-
XML
|
30
|
-
|
31
|
-
pager = @pager_digestor.from_xml_string(xml_response, :results)
|
32
|
-
pager.should == nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should digest from xml and populate all properties" do
|
36
|
-
|
37
|
-
xml_response = <<XML
|
38
|
-
<pager a="b">
|
39
|
-
<page>3</page>
|
40
|
-
<totalItems>99</totalItems>
|
41
|
-
<pageSize>22</pageSize>
|
42
|
-
</pager>
|
43
|
-
XML
|
44
|
-
|
45
|
-
pager = @pager_digestor.from_xml_string(xml_response, :pager)
|
46
|
-
pager.page.should == 3
|
47
|
-
pager.page_size.should == 22
|
48
|
-
pager.total_items.should == 99
|
49
|
-
end
|
50
|
-
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "PagerDigestor" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@pager_digestor = Sevendigital::PagerDigestor.new(nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
11
|
+
|
12
|
+
xml_response = <<XML
|
13
|
+
<release id="123">
|
14
|
+
<name>expected artist name</name>
|
15
|
+
</release>
|
16
|
+
XML
|
17
|
+
|
18
|
+
running {@pager_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not digest if paging info is missing from xml but spit out nil" do
|
22
|
+
|
23
|
+
xml_response = <<XML
|
24
|
+
<results id="123">
|
25
|
+
<page>3</page>
|
26
|
+
<totalItems>99</totalItems>
|
27
|
+
<pageSizeElementMissing>22</pageSizeElementMissing>
|
28
|
+
</results>
|
29
|
+
XML
|
30
|
+
|
31
|
+
pager = @pager_digestor.from_xml_string(xml_response, :results)
|
32
|
+
pager.should == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should digest from xml and populate all properties" do
|
36
|
+
|
37
|
+
xml_response = <<XML
|
38
|
+
<pager a="b">
|
39
|
+
<page>3</page>
|
40
|
+
<totalItems>99</totalItems>
|
41
|
+
<pageSize>22</pageSize>
|
42
|
+
</pager>
|
43
|
+
XML
|
44
|
+
|
45
|
+
pager = @pager_digestor.from_xml_string(xml_response, :pager)
|
46
|
+
pager.page.should == 3
|
47
|
+
pager.page_size.should == 22
|
48
|
+
pager.total_items.should == 99
|
49
|
+
end
|
50
|
+
|
51
51
|
end
|
@@ -1,73 +1,73 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
3
|
-
|
4
|
-
describe "PriceDigestor" do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@price_digestor = Sevendigital::PriceDigestor.new(nil)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should not digest from invalid xml but throw up (exception)" do
|
11
|
-
|
12
|
-
xml_response = <<XML
|
13
|
-
<xxx>
|
14
|
-
<currency code="XXX">X</currency>
|
15
|
-
</xxx>
|
16
|
-
XML
|
17
|
-
|
18
|
-
running {@price_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should parse from xml and populate minimum available properties" do
|
22
|
-
|
23
|
-
xml_response = <<XML
|
24
|
-
<price>
|
25
|
-
<currency code="GBP">£</currency>
|
26
|
-
<value>1.79</value>
|
27
|
-
<formattedPrice>£1.79</formattedPrice>
|
28
|
-
<onSale>true</onSale>
|
29
|
-
</price>
|
30
|
-
XML
|
31
|
-
|
32
|
-
price = @price_digestor.from_xml_string(xml_response)
|
33
|
-
price.currency_code.should == :GBP
|
34
|
-
price.currency_symbol.should == "£"
|
35
|
-
price.value.should == 1.79
|
36
|
-
price.formatted_price.should == "£1.79"
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should parse from xml and populate N/A price" do
|
41
|
-
|
42
|
-
xml_response = <<XML
|
43
|
-
<price>
|
44
|
-
<currency code="GBP">£</currency>
|
45
|
-
<value />
|
46
|
-
<formattedPrice>N/A</formattedPrice>
|
47
|
-
<onSale>false</onSale>
|
48
|
-
</price>
|
49
|
-
XML
|
50
|
-
|
51
|
-
price = @price_digestor.from_xml_string(xml_response)
|
52
|
-
price.currency_code.should == :GBP
|
53
|
-
price.currency_symbol.should == "£"
|
54
|
-
price.value.should == nil
|
55
|
-
price.formatted_price.should == "N/A"
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should parse from xml and populate all properties" do
|
60
|
-
|
61
|
-
xml_response = load_sample_object_xml("price")
|
62
|
-
|
63
|
-
price = @price_digestor.from_xml_string(xml_response)
|
64
|
-
price.currency_code.should == :GBP
|
65
|
-
price.currency_symbol.should == "£"
|
66
|
-
price.value.should == 1.79
|
67
|
-
price.formatted_price.should == "£1.79"
|
68
|
-
price.rrp.should == 1.99
|
69
|
-
price.formatted_rrp.should == "£1.99"
|
70
|
-
price.on_sale.should == true
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
3
|
+
|
4
|
+
describe "PriceDigestor" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@price_digestor = Sevendigital::PriceDigestor.new(nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
11
|
+
|
12
|
+
xml_response = <<XML
|
13
|
+
<xxx>
|
14
|
+
<currency code="XXX">X</currency>
|
15
|
+
</xxx>
|
16
|
+
XML
|
17
|
+
|
18
|
+
running {@price_digestor.from_xml_string(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse from xml and populate minimum available properties" do
|
22
|
+
|
23
|
+
xml_response = <<XML
|
24
|
+
<price>
|
25
|
+
<currency code="GBP">£</currency>
|
26
|
+
<value>1.79</value>
|
27
|
+
<formattedPrice>£1.79</formattedPrice>
|
28
|
+
<onSale>true</onSale>
|
29
|
+
</price>
|
30
|
+
XML
|
31
|
+
|
32
|
+
price = @price_digestor.from_xml_string(xml_response)
|
33
|
+
price.currency_code.should == :GBP
|
34
|
+
price.currency_symbol.should == "£"
|
35
|
+
price.value.should == 1.79
|
36
|
+
price.formatted_price.should == "£1.79"
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse from xml and populate N/A price" do
|
41
|
+
|
42
|
+
xml_response = <<XML
|
43
|
+
<price>
|
44
|
+
<currency code="GBP">£</currency>
|
45
|
+
<value />
|
46
|
+
<formattedPrice>N/A</formattedPrice>
|
47
|
+
<onSale>false</onSale>
|
48
|
+
</price>
|
49
|
+
XML
|
50
|
+
|
51
|
+
price = @price_digestor.from_xml_string(xml_response)
|
52
|
+
price.currency_code.should == :GBP
|
53
|
+
price.currency_symbol.should == "£"
|
54
|
+
price.value.should == nil
|
55
|
+
price.formatted_price.should == "N/A"
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should parse from xml and populate all properties" do
|
60
|
+
|
61
|
+
xml_response = load_sample_object_xml("price")
|
62
|
+
|
63
|
+
price = @price_digestor.from_xml_string(xml_response)
|
64
|
+
price.currency_code.should == :GBP
|
65
|
+
price.currency_symbol.should == "£"
|
66
|
+
price.value.should == 1.79
|
67
|
+
price.formatted_price.should == "£1.79"
|
68
|
+
price.rrp.should == 1.99
|
69
|
+
price.formatted_rrp.should == "£1.99"
|
70
|
+
price.on_sale.should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -1,115 +1,115 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'date'
|
3
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
4
|
-
|
5
|
-
describe "ReleaseDigestor" do
|
6
|
-
|
7
|
-
before do
|
8
|
-
@release_digestor = Sevendigital::ReleaseDigestor.new(Sevendigital::Client.new(nil))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not digest from invalid xml but throw up (exception)" do
|
12
|
-
|
13
|
-
xml_response = <<XML
|
14
|
-
<artist id="123">
|
15
|
-
<name>expected artist name</name>
|
16
|
-
</artist>
|
17
|
-
XML
|
18
|
-
|
19
|
-
running {@release_digestor.from_xml_doc(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should digest release xml and populate minimum available properties" do
|
23
|
-
|
24
|
-
xml_response = <<XML
|
25
|
-
<release id="123">
|
26
|
-
<title>expected release title</title>
|
27
|
-
<artist id="345">
|
28
|
-
<name>expected artist name</name>
|
29
|
-
<appearsAs>expected displayed artist name</appearsAs>
|
30
|
-
</artist>
|
31
|
-
</release>
|
32
|
-
XML
|
33
|
-
|
34
|
-
release = @release_digestor.from_xml_string(xml_response)
|
35
|
-
release.id.should == 123
|
36
|
-
release.title.should == "expected release title"
|
37
|
-
release.artist.id.should == 345
|
38
|
-
release.artist.name.should == "expected artist name"
|
39
|
-
release.artist.appears_as == "expected displayed artist name"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should digest release xml and populate all available properties" do
|
43
|
-
|
44
|
-
xml_response = load_sample_object_xml("release")
|
45
|
-
|
46
|
-
release = @release_digestor.from_xml_string(xml_response)
|
47
|
-
|
48
|
-
release.id.should == 155408
|
49
|
-
release.title.should == "Dreams"
|
50
|
-
release.version.should == "UK"
|
51
|
-
release.type.should == :album
|
52
|
-
release.barcode.should == "00602517512078"
|
53
|
-
release.year.should == 2007
|
54
|
-
release.explicit_content.should == false
|
55
|
-
release.artist.id.should == 29755
|
56
|
-
release.artist.name.should == "The Whitest Boy Alive"
|
57
|
-
release.artist.appears_as.should == "The Whitest Boy Alive"
|
58
|
-
release.release_date.should == DateTime.new(2007,10,22,0,0,0, 1.quo(24))
|
59
|
-
release.added_date.should == DateTime.new(2007,10,11,11,18,29, 0)
|
60
|
-
release.price.currency_code.should == :GBP
|
61
|
-
release.price.currency_symbol.should == "£"
|
62
|
-
release.price.value.should == 5
|
63
|
-
release.price.formatted_price.should == "£5.00"
|
64
|
-
release.price.rrp.should == 7.79
|
65
|
-
release.price.formatted_rrp.should == "£7.79"
|
66
|
-
release.price.on_sale.should == true
|
67
|
-
release.formats.size.should == 2
|
68
|
-
release.formats[0].id.should == 17
|
69
|
-
release.formats[1].id.should == 1
|
70
|
-
release.label.id.should == 40
|
71
|
-
release.label.name.should == "Universal-Island Records Ltd."
|
72
|
-
release.image.should == "http://cdn.7static.com/static/img/sleeveart/00/001/554/0000155408_50.jpg"
|
73
|
-
release.url.should == "http://www.7digital.com/artists/the-whitest-boy-alive/dreams-(1)/?partner=123"
|
74
|
-
release
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should digest xml containing list of releases and return a paginated array" do
|
78
|
-
|
79
|
-
xml_response = load_sample_object_xml("release_list")
|
80
|
-
|
81
|
-
releases = @release_digestor.list_from_xml_string(xml_response, :results)
|
82
|
-
releases[0].id.should == 123
|
83
|
-
releases[0].artist.id.should == 345
|
84
|
-
releases[1].id.should == 456
|
85
|
-
releases[1].artist.id.should == 789
|
86
|
-
releases.size.should == 2
|
87
|
-
releases.total_entries.should == 50
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should digest xml containing empty list of releases and return an empty paginated array" do
|
92
|
-
|
93
|
-
xml_response = load_sample_object_xml("release_list_empty")
|
94
|
-
|
95
|
-
releases = @release_digestor.list_from_xml_string(xml_response, :results)
|
96
|
-
releases.size.should == 0
|
97
|
-
releases.total_entries.should == 0
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should digest xml containing nested list of releases and return a paginated array" do
|
102
|
-
|
103
|
-
xml_response = load_sample_object_xml("nested_release_list")
|
104
|
-
|
105
|
-
releases = @release_digestor.nested_list_from_xml_string(xml_response, :results, :result)
|
106
|
-
releases[0].id.should == 123
|
107
|
-
releases[0].artist.id.should == 345
|
108
|
-
releases[1].id.should == 456
|
109
|
-
releases[1].artist.id.should == 789
|
110
|
-
releases.size.should == 2
|
111
|
-
releases.total_entries.should == 50
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
require 'date'
|
3
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
4
|
+
|
5
|
+
describe "ReleaseDigestor" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@release_digestor = Sevendigital::ReleaseDigestor.new(Sevendigital::Client.new(nil))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not digest from invalid xml but throw up (exception)" do
|
12
|
+
|
13
|
+
xml_response = <<XML
|
14
|
+
<artist id="123">
|
15
|
+
<name>expected artist name</name>
|
16
|
+
</artist>
|
17
|
+
XML
|
18
|
+
|
19
|
+
running {@release_digestor.from_xml_doc(xml_response)}.should raise_error(Sevendigital::DigestiveProblem)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should digest release xml and populate minimum available properties" do
|
23
|
+
|
24
|
+
xml_response = <<XML
|
25
|
+
<release id="123">
|
26
|
+
<title>expected release title</title>
|
27
|
+
<artist id="345">
|
28
|
+
<name>expected artist name</name>
|
29
|
+
<appearsAs>expected displayed artist name</appearsAs>
|
30
|
+
</artist>
|
31
|
+
</release>
|
32
|
+
XML
|
33
|
+
|
34
|
+
release = @release_digestor.from_xml_string(xml_response)
|
35
|
+
release.id.should == 123
|
36
|
+
release.title.should == "expected release title"
|
37
|
+
release.artist.id.should == 345
|
38
|
+
release.artist.name.should == "expected artist name"
|
39
|
+
release.artist.appears_as == "expected displayed artist name"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should digest release xml and populate all available properties" do
|
43
|
+
|
44
|
+
xml_response = load_sample_object_xml("release")
|
45
|
+
|
46
|
+
release = @release_digestor.from_xml_string(xml_response)
|
47
|
+
|
48
|
+
release.id.should == 155408
|
49
|
+
release.title.should == "Dreams"
|
50
|
+
release.version.should == "UK"
|
51
|
+
release.type.should == :album
|
52
|
+
release.barcode.should == "00602517512078"
|
53
|
+
release.year.should == 2007
|
54
|
+
release.explicit_content.should == false
|
55
|
+
release.artist.id.should == 29755
|
56
|
+
release.artist.name.should == "The Whitest Boy Alive"
|
57
|
+
release.artist.appears_as.should == "The Whitest Boy Alive"
|
58
|
+
release.release_date.should == DateTime.new(2007,10,22,0,0,0, 1.quo(24))
|
59
|
+
release.added_date.should == DateTime.new(2007,10,11,11,18,29, 0)
|
60
|
+
release.price.currency_code.should == :GBP
|
61
|
+
release.price.currency_symbol.should == "£"
|
62
|
+
release.price.value.should == 5
|
63
|
+
release.price.formatted_price.should == "£5.00"
|
64
|
+
release.price.rrp.should == 7.79
|
65
|
+
release.price.formatted_rrp.should == "£7.79"
|
66
|
+
release.price.on_sale.should == true
|
67
|
+
release.formats.size.should == 2
|
68
|
+
release.formats[0].id.should == 17
|
69
|
+
release.formats[1].id.should == 1
|
70
|
+
release.label.id.should == 40
|
71
|
+
release.label.name.should == "Universal-Island Records Ltd."
|
72
|
+
release.image.should == "http://cdn.7static.com/static/img/sleeveart/00/001/554/0000155408_50.jpg"
|
73
|
+
release.url.should == "http://www.7digital.com/artists/the-whitest-boy-alive/dreams-(1)/?partner=123"
|
74
|
+
release
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should digest xml containing list of releases and return a paginated array" do
|
78
|
+
|
79
|
+
xml_response = load_sample_object_xml("release_list")
|
80
|
+
|
81
|
+
releases = @release_digestor.list_from_xml_string(xml_response, :results)
|
82
|
+
releases[0].id.should == 123
|
83
|
+
releases[0].artist.id.should == 345
|
84
|
+
releases[1].id.should == 456
|
85
|
+
releases[1].artist.id.should == 789
|
86
|
+
releases.size.should == 2
|
87
|
+
releases.total_entries.should == 50
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should digest xml containing empty list of releases and return an empty paginated array" do
|
92
|
+
|
93
|
+
xml_response = load_sample_object_xml("release_list_empty")
|
94
|
+
|
95
|
+
releases = @release_digestor.list_from_xml_string(xml_response, :results)
|
96
|
+
releases.size.should == 0
|
97
|
+
releases.total_entries.should == 0
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should digest xml containing nested list of releases and return a paginated array" do
|
102
|
+
|
103
|
+
xml_response = load_sample_object_xml("nested_release_list")
|
104
|
+
|
105
|
+
releases = @release_digestor.nested_list_from_xml_string(xml_response, :results, :result)
|
106
|
+
releases[0].id.should == 123
|
107
|
+
releases[0].artist.id.should == 345
|
108
|
+
releases[1].id.should == 456
|
109
|
+
releases[1].artist.id.should == 789
|
110
|
+
releases.size.should == 2
|
111
|
+
releases.total_entries.should == 50
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|