dropcaster 0.0.4 → 0.0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,89 +1,90 @@
1
- require 'helper'
2
- require 'xml/libxml'
3
-
4
- class TestChannelXML < Test::Unit::TestCase
5
- include DropcasterTest
6
-
7
- def setup
8
- @options = YAML.load_file(File.join(FIXTURES_DIR, Dropcaster::CHANNEL_YML))
9
- @channel = channel_node(channel_rss)
10
- end
11
-
12
- #
13
- # Returnes the XML node for the channel passed as XML string
14
- #
15
- def channel_node(rss)
16
- XML::Document.string(rss).find("//rss/channel").first
17
- end
18
-
19
- #
20
- # Returnes the channel under test as XML string
21
- #
22
- # Subclasses may overwrite this method in order to re-use the tests in this class, while
23
- # constructing the XML string in a different way
24
- #
25
- def channel_rss
26
- Dropcaster::Channel.new(FIXTURES_DIR, @options).to_rss
27
- end
28
-
29
- def test_item
30
- item = @channel.find("item").first
31
- assert(item)
32
-
33
- assert_equal('iTunes Name', item.find('title').first.content)
34
- assert_equal('iTunes Artist', item.find('itunes:author', NS_ITUNES).first.content)
35
- assert_equal('iTunes Description (Video Pane)', item.find('itunes:summary', NS_ITUNES).first.content)
36
- assert_equal('http://www.example.com/podcasts/everything/AllAboutEverything.jpg', item.find('itunes:image', NS_ITUNES).first['href'])
37
-
38
- enclosure = item.find('enclosure').first
39
- assert(enclosure)
40
- assert_equal('http://www.example.com/podcasts/everything/test/fixtures/iTunes.mp3', enclosure['url'])
41
- assert_equal('58119', enclosure['length'])
42
- assert_equal('audio/mp3', enclosure['type'])
43
-
44
- guid = item.find('guid').first
45
- assert(guid)
46
- assert_equal('false', guid['isPermaLink'])
47
- assert_equal('77bf84447c0f69ce4a33a18b0ae1e030b82010de', guid.content)
48
-
49
- assert_equal('Wed, 05 Oct 2011 21:32:26 +0200', item.find('pubDate').first.content)
50
- assert_equal('3', item.find('itunes:duration', NS_ITUNES).first.content)
51
- end
52
-
53
- def test_attributes_mandatory
54
- options = {:title => 'Test Channel',
55
- :url => 'http://www.example.com/',
56
- :description => 'A test channel',
57
- :enclosures_url => 'http://www.example.com/foo/bar',
58
- }
59
-
60
- channel = channel_node(Dropcaster::Channel.new(FIXTURES_DIR, options).to_rss)
61
- assert_equal('Test Channel', channel.find('title').first.content)
62
- assert_equal('http://www.example.com/', channel.find('link').first.content)
63
- assert_equal('A test channel', channel.find('description').first.content)
64
- end
65
-
66
- def test_attributes_complete
67
- assert_equal(@options[:title], @channel.find('title').first.content)
68
- assert_equal(@options[:url], @channel.find('link').first.content)
69
- assert_equal(@options[:description], @channel.find('description').first.content)
70
- assert_equal(@options[:subtitle], @channel.find('itunes:subtitle', NS_ITUNES).first.content)
71
- assert_equal(@options[:language], @channel.find('language').first.content)
72
- assert_equal(@options[:copyright], @channel.find('copyright').first.content)
73
- assert_equal(@options[:author], @channel.find('itunes:author', NS_ITUNES).first.content)
74
-
75
- owner = @channel.find('itunes:owner', NS_ITUNES).first
76
- assert_equal(@options[:owner][:name], owner.find('itunes:name', NS_ITUNES).first.content)
77
- assert_equal(@options[:owner][:email], owner.find('itunes:email', NS_ITUNES).first.content)
78
- assert_equal(URI.join(@options[:url], @options[:image_url]).to_s, @channel.find('itunes:image', NS_ITUNES).first['href'])
79
-
80
- categories = @channel.find('itunes:category', NS_ITUNES)
81
- assert_not_nil(categories)
82
- assert_equal(2, categories.size)
83
- assert_equal('Technology', categories.first['text'])
84
- assert_equal('Gadgets', categories.first.find('itunes:category', NS_ITUNES).first['text'])
85
- assert_equal('TV & Film', categories.last['text'])
86
-
87
- assert_equal(@options[:explicit] ? 'Yes' : 'No', @channel.find('itunes:explicit', NS_ITUNES).first.content)
88
- end
89
- end
1
+ require 'helper'
2
+ require 'xml/libxml'
3
+ require 'pry'
4
+
5
+ class TestChannelXML < MiniTest::Test
6
+ include DropcasterTest
7
+
8
+ def setup
9
+ @options = YAML.load_file(File.join(FIXTURES_DIR, Dropcaster::CHANNEL_YML))
10
+ @channel = channel_node(channel_rss)
11
+ end
12
+
13
+ #
14
+ # Returnes the XML node for the channel passed as XML string
15
+ #
16
+ def channel_node(rss)
17
+ XML::Document.string(rss).find("//rss/channel").first
18
+ end
19
+
20
+ #
21
+ # Returnes the channel under test as XML string
22
+ #
23
+ # Subclasses may overwrite this method in order to re-use the tests in this class, while
24
+ # constructing the XML string in a different way
25
+ #
26
+ def channel_rss
27
+ Dropcaster::Channel.new(FIXTURES_DIR, @options).to_rss
28
+ end
29
+
30
+ def test_item
31
+ item = @channel.find("item").first
32
+ assert(item)
33
+
34
+ assert_equal('iTunes Name', item.find('title').first.content)
35
+ assert_equal('iTunes Artist', item.find('itunes:author', NS_ITUNES).first.content)
36
+ assert_equal('iTunes Description (Video Pane)', item.find('itunes:summary', NS_ITUNES).first.content)
37
+ assert_equal('http://www.example.com/podcasts/everything/AllAboutEverything.jpg', item.find('itunes:image', NS_ITUNES).first['href'])
38
+
39
+ enclosure = item.find('enclosure').first
40
+ assert(enclosure)
41
+ assert_equal('http://www.example.com/podcasts/everything/test/fixtures/iTunes.mp3', enclosure['url'])
42
+ assert_equal('58119', enclosure['length'])
43
+ assert_equal('audio/mp3', enclosure['type'])
44
+
45
+ guid = item.find('guid').first
46
+ assert(guid)
47
+ assert_equal('false', guid['isPermaLink'])
48
+ assert_equal('77bf84447c0f69ce4a33a18b0ae1e030b82010de', guid.content)
49
+
50
+ assert_equal('Wed, 05 Oct 2011 13:32:26 -0600', item.find('pubDate').first.content)
51
+ assert_equal('3', item.find('itunes:duration', NS_ITUNES).first.content)
52
+ end
53
+
54
+ def test_attributes_mandatory
55
+ options = {:title => 'Test Channel',
56
+ :url => 'http://www.example.com/',
57
+ :description => 'A test channel',
58
+ :enclosures_url => 'http://www.example.com/foo/bar',
59
+ }
60
+
61
+ channel = channel_node(Dropcaster::Channel.new(FIXTURES_DIR, options).to_rss)
62
+ assert_equal('Test Channel', channel.find('title').first.content)
63
+ assert_equal('http://www.example.com/', channel.find('link').first.content)
64
+ assert_equal('A test channel', channel.find('description').first.content)
65
+ end
66
+
67
+ def test_attributes_complete
68
+ assert_equal(@options[:title], @channel.find('title').first.content)
69
+ assert_equal(@options[:url], @channel.find('link').first.content)
70
+ assert_equal(@options[:description], @channel.find('description').first.content)
71
+ assert_equal(@options[:subtitle], @channel.find('itunes:subtitle', NS_ITUNES).first.content)
72
+ assert_equal(@options[:language], @channel.find('language').first.content)
73
+ assert_equal(@options[:copyright], @channel.find('copyright').first.content)
74
+ assert_equal(@options[:author], @channel.find('itunes:author', NS_ITUNES).first.content)
75
+
76
+ owner = @channel.find('itunes:owner', NS_ITUNES).first
77
+ assert_equal(@options[:owner][:name], owner.find('itunes:name', NS_ITUNES).first.content)
78
+ assert_equal(@options[:owner][:email], owner.find('itunes:email', NS_ITUNES).first.content)
79
+ assert_equal(URI.join(@options[:url], @options[:image_url]).to_s, @channel.find('itunes:image', NS_ITUNES).first['href'])
80
+
81
+ categories = @channel.find('itunes:category', NS_ITUNES)
82
+ refute_nil(categories)
83
+ assert_equal(2, categories.size)
84
+ assert_equal('Technology', categories.first['text'])
85
+ assert_equal('Gadgets', categories.first.find('itunes:category', NS_ITUNES).first['text'])
86
+ assert_equal('TV & Film', categories.last['text'])
87
+
88
+ assert_equal(@options[:explicit] ? 'Yes' : 'No', @channel.find('itunes:explicit', NS_ITUNES).first.content)
89
+ end
90
+ end
@@ -1,63 +1,51 @@
1
- require 'helper'
2
-
3
- class TestItem < Test::Unit::TestCase
4
- include DropcasterTest
5
-
6
- def setup
7
- @item = Dropcaster::Item.new(FIXTURE_ITUNES_MP3)
8
- end
9
-
10
- def test_basics
11
- assert_in_delta(3, @item.duration, 0.005)
12
- assert_equal(58119, @item.file_size)
13
- assert_equal('77bf84447c0f69ce4a33a18b0ae1e030b82010de', @item.uuid)
14
- assert_equal(1317843146, @item.pub_date.to_i)
15
- assert_equal('test/fixtures/iTunes.mp3', @item.file_name)
16
- end
17
-
18
- def test_tag
19
- assert_equal('iTunes Artist', @item.tag.artist)
20
- assert_equal('iTunes Genre', @item.tag.genre_s)
21
- assert_equal('iTunes Name', @item.tag.title)
22
- assert_equal(' 00007032 00006EA2 0000A049 00009735 00000559 0000096E 00008000 00008000 00000017 00000017', @item.tag.comments)
23
- assert_equal('iTunes Album', @item.tag.album)
24
- assert_equal(1970, @item.tag.year)
25
- assert_equal(42, @item.tag.tracknum)
26
- end
27
-
28
- def test_tag2
29
- assert_equal('iTunes Artist', @item.tag2.TP1)
30
- assert_equal('iTunes Genre', @item.tag2.TCO)
31
- assert_equal('iTunes Name', @item.tag2.TT2)
32
- assert_equal('iTunes Album', @item.tag2.TAL)
33
- assert_equal('1970', @item.tag2.TYE)
34
- assert_equal('iTunes Album Artist', @item.tag2.TP2)
35
- assert_equal('111', @item.tag2.TBP)
36
- assert_equal('42/99', @item.tag2.TRK)
37
- assert_equal('11', @item.tag2.TPA)
38
- assert_equal('iTunes Grouping', @item.tag2.TT1)
39
- assert_equal('iTunes Description (Video Pane)', @item.tag2.TT3)
40
- assert_equal('iTunes Composer', @item.tag2.TCM)
41
- end
42
-
43
- def test_lyrics
44
- assert_equal(1, @item.lyrics.size)
45
- assert_equal("iTunes Lyrics Line 1\niTunes Lyrics Line 2", @item.lyrics['eng'])
46
- end
47
-
48
- def test_comment_remove_itunes_crap
49
- item = Dropcaster::Item.new(FIXTURE_ITUNES_MP3, {:strip_itunes_private => true})
50
- assert_equal('iTunes Comments (Info Pane)', item.tag2.COM[0])
51
- end
52
-
53
- def test_comment_leave_itunes_crap
54
- item = Dropcaster::Item.new(FIXTURE_ITUNES_MP3, {:strip_itunes_private => false})
55
- assert_equal(' 00007032 00006EA2 0000A049 00009735 00000559 0000096E 00008000 00008000 00000017 00000017', item.tag2.COM[0])
56
- assert_equal('iTunes Comments (Info Pane)', item.tag2.COM[1])
57
- end
58
-
59
- def test_tag2_comment
60
- assert_equal(' 00007032 00006EA2 0000A049 00009735 00000559 0000096E 00008000 00008000 00000017 00000017', @item.tag2.COM[0])
61
- assert_equal('iTunes Comments (Info Pane)', @item.tag2.COM[1])
62
- end
63
- end
1
+ require 'helper'
2
+
3
+ class TestItem < MiniTest::Test
4
+ include DropcasterTest
5
+
6
+ def setup
7
+ @item = Dropcaster::Item.new(FIXTURE_ITUNES_MP3)
8
+ end
9
+
10
+ def test_basics
11
+ assert_in_delta(3, @item.duration, 0.005)
12
+ assert_equal(58119, @item.file_size)
13
+ assert_equal('77bf84447c0f69ce4a33a18b0ae1e030b82010de', @item.uuid)
14
+ assert_equal(1392932984, @item.pub_date.to_i)
15
+ assert_equal('test/fixtures/iTunes.mp3', @item.file_name)
16
+ end
17
+
18
+ def test_tag
19
+ assert_equal('iTunes Artist', @item.tag.artist)
20
+ assert_equal('iTunes Genre', @item.tag.genre_s)
21
+ assert_equal('iTunes Name', @item.tag.title)
22
+ assert_equal(' 00007032 00006EA2 0000A049 00009735 00000559 0000096E 00008000 00008000 00000017 00000017', @item.tag.comments)
23
+ assert_equal('iTunes Album', @item.tag.album)
24
+ assert_equal(1970, @item.tag.year)
25
+ assert_equal(42, @item.tag.tracknum)
26
+ end
27
+
28
+ def test_tag2
29
+ assert_equal('iTunes Artist', @item.tag2.TP1)
30
+ assert_equal('iTunes Genre', @item.tag2.TCO)
31
+ assert_equal('iTunes Name', @item.tag2.TT2)
32
+ assert_equal('iTunes Album', @item.tag2.TAL)
33
+ assert_equal('1970', @item.tag2.TYE)
34
+ assert_equal('iTunes Album Artist', @item.tag2.TP2)
35
+ assert_equal('111', @item.tag2.TBP)
36
+ assert_equal('42/99', @item.tag2.TRK)
37
+ assert_equal('11', @item.tag2.TPA)
38
+ assert_equal('iTunes Grouping', @item.tag2.TT1)
39
+ assert_equal('iTunes Description (Video Pane)', @item.tag2.TT3)
40
+ assert_equal('iTunes Composer', @item.tag2.TCM)
41
+ end
42
+
43
+ def test_lyrics
44
+ assert_equal(1, @item.lyrics.size)
45
+ assert_equal("iTunes Lyrics Line 1\niTunes Lyrics Line 2", @item.lyrics['eng'])
46
+ end
47
+
48
+ def test_tag2_comment
49
+ assert_equal('iTunes Comments (Info Pane)', @item.tag2.COM[1])
50
+ end
51
+ end