Merge lp:~rockstar/entertainer/trial-integration into lp:entertainer

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/entertainer/trial-integration
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~rockstar/entertainer/trial-integration
Reviewer Review Type Date Requested Status
Matt Layman Approve
Review via email: mp+3281@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

This branch basically just makes all tests run by twisted's trial, which will
be required when for my next branch. The run_test.py script is gone, but if
you're like me, you've been using `make test` and in which case, you'll notice
only a difference in the output.

Also, tests needed to be renamed, and while I was at it, I consolidated the
tests from entertainerlib.frontend.medialibrary.music into one single file.
That's the extent of this branch.

The diff is relatively large, but only because there was the consolidation of
the music tests.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Matt Layman (mblayman) wrote :

I'll approve, but I have questions.

What is the actual new work on this branch? Just removing the run_tests, renaming the files, and moving the music tests? I can see that the to_dict branch was merged in, as was the small change to GNOME from Kmos.

There are twenty missing tests (234 to 214) between the trunk and your branch. Any clue where those tests went? Did you consolidate all the music tests correctly?

review: Approve
Revision history for this message
Paul Hummer (rockstar) wrote :

> What is the actual new work on this branch? Just removing the run_tests,
> renaming the files, and moving the music tests? I can see that the to_dict
> branch was merged in, as was the small change to GNOME from Kmos.
>

Well, originally, I started out trying to integrate trial's python API into the
current test runner. I abandoned that idea when I realized I'd rather not
maintain more code than I needed. That's why this results in such a small
amount of work now. Smarter not harder or something like that.

> There are twenty missing tests (234 to 214) between the trunk and your
> branch. Any clue where those tests went? Did you consolidate all the music
> tests correctly?

I'm checking now, but basically, the tests were merged by doing
`cat this_test.py >> that_test.py` so I can't see how I missed something. It
might be that trial is not running inherited tests of something, where the
original test runner would have (and maybe the former is the correct
behavior). I'll verify and post what I find.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Paul Hummer (rockstar) wrote :

> > There are twenty missing tests (234 to 214) between the trunk and your
> > branch. Any clue where those tests went? Did you consolidate all the music
> > tests correctly?
>
> I'm checking now, but basically, the tests were merged by doing
> `cat this_test.py >> that_test.py` so I can't see how I missed something.
> It might be that trial is not running inherited tests of something, where
> the original test runner would have (and maybe the former is the correct
> behavior). I'll verify and post what I find.
>

This is wierd. I run the following command in entertainerlib/tests

 grep -r "def test" * | grep -v "NOT" | wc -l

I get 215 in both trunk and my trial branch. I THINK what was happening was
that since the tests dependent on test_music were importing test_music, it was
also bringing in the test_music tests and running them again. I don't know why
there are only 214 tests running instead of 215 like the wc command claims
there are, but I've verified that this must be a trial issue in the counting,
as it's running all the tests.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Paul Hummer (rockstar) wrote :

The grep command I used will yield testBackendServerCreateConfiguration that is actually commented out, so that makes sense why there are only 214 tests run. This reorganization of tests has shown us that we were running some tests more than once.

344. By Paul Hummer

Merge from trunk and resolve conflicts

345. By Paul Hummer

Renamed screen factory test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2008-10-12 17:56:41 +0000
3+++ .bzrignore 2009-01-31 21:52:10 +0000
4@@ -1,2 +1,3 @@
5 tags
6 build
7+_trial_temp
8
9=== modified file 'Makefile'
10--- Makefile 2008-12-19 05:29:55 +0000
11+++ Makefile 2009-02-01 02:08:56 +0000
12@@ -1,7 +1,7 @@
13 PYTHON=`which python`
14 VERBOSITY=-vv
15
16-TEST=${PYTHON} run_tests.py
17+TEST=`which trial` entertainerlib.tests
18
19 LINT=pylint
20 LINT_FLAGS=--rcfile=pylintrc
21
22=== modified file 'docs/HACKING'
23--- docs/HACKING 2008-10-06 01:33:50 +0000
24+++ docs/HACKING 2009-02-01 02:08:56 +0000
25@@ -164,8 +164,7 @@
26 -----------------------------------------------------------------------
27
28 There are a few things that need to be pointed out. First, the test should
29-always inherit from unittest.TestCase?. The run_tests.py script looks for
30-tests that inherit from unittest.TestCase? and runs those tests. Second, the
31+always inherit from entertainerlib.tests.EntertainerTest?. Second, the
32 test never prints anything to stdout or stderr. If the test needs to log to a
33 file, that is fine, but please don't print anything to stdout or stderr.
34 Lastly, the tearDown removed a file that was created by the test (and is not
35
36=== modified file 'entertainerlib/backend/core/db/models.py'
37--- entertainerlib/backend/core/db/models.py 2009-01-31 06:19:39 +0000
38+++ entertainerlib/backend/core/db/models.py 2009-01-31 21:47:47 +0000
39@@ -1,5 +1,5 @@
40 '''Contains all storm ORM models'''
41-# pylint: disable-msg=W0621
42+# pylint: disable-msg=W0621,W0223
43
44 from storm.base import Storm
45 from storm.properties import Bool, DateTime, Int, Unicode
46
47=== removed file 'entertainerlib/tests/Album_test.py'
48--- entertainerlib/tests/Album_test.py 2009-01-11 02:51:18 +0000
49+++ entertainerlib/tests/Album_test.py 1970-01-01 00:00:00 +0000
50@@ -1,95 +0,0 @@
51-'''Tests frontend.medialibrary.music.Album'''
52-
53-__licence__ = "GPLv2"
54-__copyright__ = "2008, Matt Layman"
55-__author__ = "Matt Layman <laymansterms.dev@gmail.com>"
56-
57-import os
58-
59-from entertainerlib.frontend.medialibrary.music import Album, AlbumHasNoTracks
60-from entertainerlib.frontend.medialibrary.music import Track
61-from entertainerlib.tests.Music_test import TestMusic
62-
63-
64-class TestAlbum(TestMusic):
65- '''Tests Album'''
66-
67- def setUp(self):
68- """See unittest.TestCase"""
69- TestMusic.setUp(self)
70- self.album = Album('album1', self.cursor)
71-
72- def tearDown(self):
73- """Clean up after the test"""
74- TestMusic.tearDown(self)
75-
76- def testAlbumConstructor(self):
77- """Test that an Album object is properly constructed"""
78- self.assertTrue(isinstance(self.album, Album))
79-
80- def testAlbumConstructorNot(self):
81- """Test that an AlbumHasNoTracks exception is raised when the created
82- album doesn't exist in the cache"""
83- self.assertRaises(AlbumHasNoTracks, Album, 'foo', self.cursor)
84-
85- def testAlbumStr(self):
86- """Test that title is returned in string conversion"""
87- result = str(self.album)
88- self.assertEqual(result, 'album1')
89-
90- def testAlbumGetTitle(self):
91- """Test that the album title is returned"""
92- result = self.album.get_title()
93- self.assertEqual(result, 'album1')
94-
95- def testAlbumHasAlbumArt(self):
96- """Test that album art exists for the file"""
97- album_artist = "artist0 - album1"
98- album_artist = album_artist.encode("base64")
99- album_art = os.path.join(self.art_path, album_artist + ".jpg")
100- file = open(album_art, "wb")
101- file.close()
102- self.assertTrue(self.album.has_album_art())
103- if os.path.exists(album_art):
104- os.remove(album_art)
105-
106- def testAlbumHasAlbumArtNot(self):
107- """Test that missing album art is reported back"""
108- otherAlbum = Album('album1', self.cursor)
109- self.assertFalse(otherAlbum.has_album_art())
110-
111- def testAlbumGetAlbumArtUrl(self):
112- """Test that the path to the album's art is returned"""
113- result = self.album.get_album_art_url()
114- album_artist = "artist0 - album1"
115- album_artist = album_artist.encode("base64")
116- album_art = os.path.join(self.art_path, album_artist + ".jpg")
117- self.assertEqual(result, album_art)
118-
119- def testAlbumGetTracks(self):
120- """Test that all tracks for an album are returned"""
121- result = self.album.get_tracks()
122- self.assertEqual(len(result), 4)
123- for i in result:
124- self.assertTrue(isinstance(i, Track))
125-
126- def testAlbumGetNumberOfTracks(self):
127- """Test correct number of tracks from album is returned"""
128- self.assertEqual(self.album.get_number_of_tracks(), 4)
129-
130- def testAlbumGetYear(self):
131- """Test that year of album is returned"""
132- self.assertEqual(self.album.get_year(), 0)
133-
134- def testAlbumGetGenre(self):
135- """Test that genre of album is returned"""
136- self.assertEqual(self.album.get_genre(), 'genre0')
137-
138- def testAlbumGetArtist(self):
139- """Test that artist of album is returned"""
140- self.assertEqual(self.album.get_artist(), 'artist0')
141-
142- def testAlbumGetTotalLength(self):
143- """Test that total length of album is returned"""
144- self.assertEqual(self.album.get_total_length(), 8)
145-
146
147=== removed file 'entertainerlib/tests/MusicLibrary_test.py'
148--- entertainerlib/tests/MusicLibrary_test.py 2009-01-11 02:51:18 +0000
149+++ entertainerlib/tests/MusicLibrary_test.py 1970-01-01 00:00:00 +0000
150@@ -1,132 +0,0 @@
151-'''Tests MusicLibrary'''
152-
153-__licence__ = "GPLv2"
154-__copyright__ = "2008, Matt Layman"
155-__author__ = "Matt Layman <laymansterms.dev@gmail.com>"
156-
157-from entertainerlib.frontend.medialibrary.music import MusicLibrary
158-from entertainerlib.frontend.medialibrary.music import Album, Track
159-from entertainerlib.tests.Music_test import TestMusic
160-from entertainerlib.tests.helpers import MockBackendConnection
161-
162-class TestMusicLibrary(TestMusic):
163- '''Tests MusicLibrary'''
164-
165- def setUp(self):
166- TestMusic.setUp(self)
167- try:
168- self.backend_connection = MockBackendConnection()
169- except:
170- print "\nbackend_connection failed"
171- self.musiclibrary = MusicLibrary(self.backend_connection)
172-
173- def tearDown(self):
174- self.backend_connection.close_connection()
175- TestMusic.tearDown(self)
176-
177- def testMusicLibraryConstructor(self):
178- """testMusicLibraryContructor - Ensures instantiation of MusicLibrary
179- class"""
180- self.assertTrue(isinstance(self.musiclibrary, MusicLibrary))
181-
182- def testGetAllArtists(self):
183- """testGetAllArtists - Ensures that all artists are returned from
184- the music library"""
185- result = self.musiclibrary.get_all_artists()
186- self.assertEqual(result, ['artist0'])
187-
188- def testGetAllTracks(self):
189- """testGetAllTracks - Ensures that all tracks are returned"""
190- result = self.musiclibrary.get_all_tracks()
191- for i in result:
192- self.assertTrue(isinstance(i, Track))
193- self.assertEqual(len(result), 8)
194-
195- def testGetTracksByGenre(self):
196- """testGetTracksByGenre - Ensures tracks of a certain genre are
197- returned"""
198- result = self.musiclibrary.get_tracks_by_genre('genre0')
199- self.assertEqual(len(result), 4)
200- for i in result:
201- self.assertEqual(i.get_genre(), 'genre0')
202-
203- def testGetTracksByMissingGenre(self):
204- """testGetTracksByMissingGenre - Ensures proper handling of a missing
205- genre"""
206- self.assertEquals(
207- len(self.musiclibrary.get_tracks_by_genre('foo-bar-baz**')), 0)
208-
209- def testGetTracksByArtist(self):
210- """testGetTracksByArtist - Ensure tracks by a certain artist are
211- returned"""
212- result = self.musiclibrary.get_tracks_by_artist('artist0')
213- self.assertEqual(len(result), 8)
214- for i in result:
215- self.assertEqual(i.get_artist(), 'artist0')
216-
217- def testGetTracksByUnknownArtist(self):
218- """testGetTracksByUnknownArtist - Ensure proper handling of an missing
219- artist in the cache"""
220- self.assertEquals(
221- len(self.musiclibrary.get_tracks_by_artist('foo')), 0)
222-
223- def testGetAllAlbums(self):
224- """testGetAllAlbums - Ensures all albums are returned"""
225- result = self.musiclibrary.get_all_albums()
226- for i in result:
227- self.assertTrue(isinstance(i, Album))
228- self.assertEqual(len(result), 2)
229-
230- def testGetAlbumsByArtist(self):
231- """testGetAlbumsByArtist - Ensures correct albums by an artist is
232- returned"""
233- result = self.musiclibrary.get_albums_by_artist('artist0')
234- self.assertEqual(len(result), 2)
235- for i in result:
236- self.assertEqual(i.get_artist(), 'artist0')
237-
238- def testGetAlbumsByUnknownArtist(self):
239- """testGetAlbumsByUnknownArtist - Ensures proper handling of an
240- artist not in the cache"""
241- self.assertEquals(
242- len(self.musiclibrary.get_albums_by_artist('foo')), 0)
243-
244- def testNumberOfTracks(self):
245- """testNumberOfTracks - Ensures number of all tracks is returned"""
246- result = self.musiclibrary.number_of_tracks()
247- self.assertEqual(result, 8)
248-
249- def testNumberOfTracksByArtist(self):
250- """testNumberOfTracksByArtist - Ensures number of all tracks by one
251- artist is returned"""
252- result = self.musiclibrary.number_of_tracks_by_artist('artist0')
253- self.assertEqual(result, 8)
254-
255- def testNumberOfTracksByUnknownArtist(self):
256- """testNumberOfTracksByUnknownArtist - Ensures proper handling when
257- artist called is not in the cache"""
258- self.assertEqual(
259- self.musiclibrary.number_of_albums_by_artist('foo'), 0)
260-
261- def testNumberOfAlbumsByArtist(self):
262- """testNumberOfAlbumsByArtist - Ensures number of all albums by one
263- artist is returned"""
264- result = self.musiclibrary.number_of_albums_by_artist('artist0')
265- self.assertEqual(result, 2)
266-
267- def testNumberOfAlbumsByUnknownArtist(self):
268- """testNumberOfAlbumsByUnknownArtist - Ensures proper handling when
269- artist called is not in the cache"""
270- self.assertEqual(
271- self.musiclibrary.number_of_albums_by_artist('foo'), 0)
272-
273- def testSaveLyrics(self):
274- """testSaveLyrics - Ensures lyrics for a track are saved in the
275- database"""
276- # Only need a filename that matches something in the database, the rest
277- # of the track is for construction purposes only
278- self.track = Track('/filename/000', '', 0, '', '', '', '', 0, 1, 0, '',
279- '')
280- self.musiclibrary.save_lyrics(self.track, 'some lyrics here')
281- self.assertEqual(self.track.get_lyrics(), 'some lyrics here')
282-
283
284=== removed file 'entertainerlib/tests/README'
285--- entertainerlib/tests/README 2008-02-04 01:45:58 +0000
286+++ entertainerlib/tests/README 1970-01-01 00:00:00 +0000
287@@ -1,7 +0,0 @@
288-How to run Entertainer tests:
289-
290-I'll make this easy for you...
291-
292-./run_tests.py
293-
294-That's it. Then watch it go.
295
296=== removed file 'entertainerlib/tests/Track_test.py'
297--- entertainerlib/tests/Track_test.py 2008-12-25 01:21:19 +0000
298+++ entertainerlib/tests/Track_test.py 1970-01-01 00:00:00 +0000
299@@ -1,176 +0,0 @@
300-'''Test Track'''
301-
302-__licence__ = "GPLv2"
303-__copyright__ = "2008, Matt Layman"
304-__author__ = "Matt Layman <laymansterms.dev@gmail.com>"
305-
306-import os
307-
308-from entertainerlib.frontend.medialibrary.music import Track, TrackTypeError
309-from entertainerlib.frontend.medialibrary.music import TrackRatingOutOfRange
310-from entertainerlib.frontend.medialibrary.music import Album, AlbumHasNoTracks
311-from entertainerlib.frontend.medialibrary.playable import Playable
312-from entertainerlib.tests.Music_test import TestMusic
313-
314-
315-class TestTrack(TestMusic):
316-
317- def setUp(self):
318- TestMusic.setUp(self)
319- self.track = Track('/path/to/track.mp3', # filename
320- 'title',
321- 1, # tracknumber
322- 'artist0',
323- 'album0',
324- 'genre',
325- '128', # bitrate
326- 2008, # year
327- 5, # rating
328- 240, # length
329- 'comment',
330- 'lyrics')
331-
332- def tearDown(self):
333- TestMusic.tearDown(self)
334-
335- def testTrackConstructor(self):
336- """testTrackConstructor - Ensures that a Track object is created"""
337- self.assertTrue(isinstance(self.track, Track))
338-
339- def testTrackBadConstructor(self):
340- """testTrackBadConstructor - Ensures that bad track construction
341- raises an exception for the integer fields"""
342- for i in [2, 7, 8, 9]:
343- t = ['a', 'b', 1, 'c', 'd', 'e', 'f', 2, 3, 4, 'g', 'h']
344- t[i] = str(t[i])
345- self.assertRaises(TrackTypeError, Track, t[0], t[1], t[2], t[3],
346- t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11])
347-
348- def testTrackRatingInRange(self):
349- """testTrackRatingInRange - Ensures that the ratings in range create
350- valid Track objects"""
351- for i in range(1, 6):
352- self.track = Track('a', 'b', 1, 'c', 'd', 'e', 'f', 2, i, 3, 'g',
353- 'h')
354- self.assertTrue(isinstance(self.track, Track))
355- self.assertEqual(self.track.get_rating(), i)
356-
357- def testTrackRatingOutOfRange(self):
358- """testTrackRatingOutOfRange - Ensures that the rating raises an
359- exception for something out of range in construction"""
360- for i in [0, 6]:
361- self.assertRaises(TrackRatingOutOfRange, Track, 'a', 'b', 1, 'c',
362- 'd', 'e', 'f', 2, i, 3, 'g', 'h')
363-
364- def testTrackGetFilename(self):
365- """testTrackGetFilename - Ensures that the filename is returned"""
366- result = self.track.get_filename()
367- self.assertEqual(result, '/path/to/track.mp3')
368-
369- def testTrackGetTitle(self):
370- """testTrackGetTitle - Ensures that the title is returned"""
371- result = self.track.get_title()
372- self.assertEqual(result, 'title')
373-
374- def testTrackGetTrackNumber(self):
375- """testTrackGetTrackNumber - Ensures that the tracknumber is
376- returned"""
377- result = self.track.get_tracknumber()
378- self.assertEqual(result, 1)
379-
380- def testTrackGetArtist(self):
381- """testTrackGetArtist - Ensures that the artist is returned"""
382- result = self.track.get_artist()
383- self.assertEqual(result, 'artist0')
384-
385- def testTrackGetAlbum(self):
386- """testTrackGetAlbum - Ensures that an album object is returned"""
387- result = self.track.get_album(self.cursor)
388- self.assertTrue(isinstance(result, Album))
389- self.assertEqual(result.get_title(), 'album0')
390-
391- def testTrackGetAlbumNot(self):
392- """testTrackGetAlbumNot - Ensures that a bad album in the track
393- returns AlbumHasNoTracks"""
394- self.badTrack = Track('path', 'title', 1, 'artist',
395- 'foo-bar-baz**', # Here is the bad input
396- 'genre', '128', 2008, 5, 240, 'comment',
397- 'lyrics')
398- self.assertRaises(AlbumHasNoTracks, self.badTrack.get_album,
399- self.cursor)
400-
401- def testTrackGetAlbumArtUrlExists(self):
402- """testTrackGetAlbumArtUrl - Ensures that the album art url is
403- returned"""
404- album_artist = "artist0 - album0"
405- album_artist = album_artist.encode("base64")
406- album_art = os.path.join(self.art_path, album_artist + ".jpg")
407- file = open(album_art, "wb")
408- file.close()
409- result = self.track.get_album_art_url(self.cursor)
410- self.assertEqual(result, album_art)
411- if os.path.exists(album_art):
412- os.remove(album_art)
413-
414- def testTrackGetAlbumArtUrlNotExists(self):
415- """testTrackGetAlbumArtUrlNotExists - Ensures that when art does
416- not exist, None is returned"""
417- result = self.track.get_album_art_url(self.cursor)
418- self.assertEqual(result, None)
419-
420- def testTrackGetGenre(self):
421- """testTrackGetGenre - Ensures that the genre is returned"""
422- result = self.track.get_genre()
423- self.assertEqual(result, 'genre')
424-
425- def testTrackGetBitrate(self):
426- """testTrackGetBitrate - Ensures that the bitrate is returned"""
427- result = self.track.get_bitrate()
428- self.assertEqual(result, '128')
429-
430- def testTrackGetYear(self):
431- """testTrackGetYear - Ensures that the year is returned"""
432- result = self.track.get_year()
433- self.assertEqual(result, 2008)
434-
435- def testTrackGetRating(self):
436- """testTrackGetRating - Ensures that the rating is returned"""
437- result = self.track.get_rating()
438- self.assertEqual(result, 5)
439-
440- def testTrackGetLength(self):
441- """testTrackGetLength - Ensures that the length is returned"""
442- result = self.track.get_length()
443- self.assertEqual(result, 240)
444-
445- def testTrackGetComment(self):
446- """testTrackGetComment - Ensures that the comment is returned"""
447- result = self.track.get_comment()
448- self.assertEqual(result, 'comment')
449-
450- def testTrackGetLyrics(self):
451- """testTrackGetLyrics - Ensures that the lyrics are returned"""
452- result = self.track.get_lyrics()
453- self.assertEqual(result, 'lyrics')
454-
455- def testTrackSetLyrics(self):
456- """testTrackSetLyrics - Ensures that lyrics are properly set"""
457- self.track.set_lyrics('some new lyrics')
458- self.assertEqual(self.track.get_lyrics(), 'some new lyrics')
459-
460- def testTrackSetNoneLyrics(self):
461- """testTrackSetNoneLyrics - Ensures that lyrics are set to empty
462- string when None is passed as lyrics input"""
463- self.track.set_lyrics(None)
464- self.assertEqual(self.track.get_lyrics(), '')
465-
466- def testTrackGetType(self):
467- """testTrackGetType - Ensures that the type is returned"""
468- result = self.track.get_type()
469- self.assertEqual(result, Playable.AUDIO_STREAM)
470-
471- def testTrackGetUri(self):
472- """testTrackGetUri - Ensures that the uri is returned"""
473- result = self.track.get_uri()
474- self.assertEqual(result, 'file:///path/to/track.mp3')
475-
476
477=== modified file 'entertainerlib/tests/__init__.py'
478--- entertainerlib/tests/__init__.py 2009-01-11 22:29:20 +0000
479+++ entertainerlib/tests/__init__.py 2009-02-01 01:51:12 +0000
480@@ -6,8 +6,10 @@
481 import testtools
482
483 from entertainerlib.backend.core.db.connection import Database
484+from entertainerlib.frontend.translation_setup import TranslationSetup
485 from entertainerlib.utils.configuration import Configuration
486
487+TranslationSetup()
488
489 class EntertainerTest(testtools.TestCase):
490 '''Test for use in the Entertainer test suite.'''
491
492=== renamed file 'entertainerlib/tests/BackendServer_test.py' => 'entertainerlib/tests/test_backendserver.py'
493=== renamed file 'entertainerlib/tests/Base_test.py' => 'entertainerlib/tests/test_base.py'
494=== renamed file 'entertainerlib/tests/Configuration_test.py' => 'entertainerlib/tests/test_configuration.py'
495=== renamed file 'entertainerlib/tests/ConnectionServer_test.py' => 'entertainerlib/tests/test_connection.py'
496=== renamed file 'entertainerlib/tests/Database_test.py' => 'entertainerlib/tests/test_database.py'
497=== renamed file 'entertainerlib/tests/FeedConfigTools_test.py' => 'entertainerlib/tests/test_feedconfigtools.py'
498=== renamed file 'entertainerlib/tests/FeedEntryParser_test.py' => 'entertainerlib/tests/test_feedentryparser.py'
499=== renamed file 'entertainerlib/tests/FrontendFeed_test.py' => 'entertainerlib/tests/test_frontendfeed.py'
500=== renamed file 'entertainerlib/tests/FrontendFeedEntry_test.py' => 'entertainerlib/tests/test_frontendfeedentry.py'
501=== renamed file 'entertainerlib/tests/FrontendFeedLibrary_test.py' => 'entertainerlib/tests/test_frontendfeedlibrary.py'
502=== renamed file 'entertainerlib/tests/ImageMenuItem_test.py' => 'entertainerlib/tests/test_imagemenuitem.py'
503=== renamed file 'entertainerlib/tests/ImageThumbnailer_test.py' => 'entertainerlib/tests/test_imagethumbnailer.py'
504=== renamed file 'entertainerlib/tests/Label_test.py' => 'entertainerlib/tests/test_label.py'
505=== renamed file 'entertainerlib/tests/Logger_test.py' => 'entertainerlib/tests/test_logger.py'
506=== renamed file 'entertainerlib/tests/LyricsDownloader_test.py' => 'entertainerlib/tests/test_lyricsdownloader.py'
507=== renamed file 'entertainerlib/tests/MessageType_test.py' => 'entertainerlib/tests/test_messagetype.py'
508=== renamed file 'entertainerlib/tests/Models_test.py' => 'entertainerlib/tests/test_models.py'
509=== renamed file 'entertainerlib/tests/Music_test.py' => 'entertainerlib/tests/test_music.py'
510--- entertainerlib/tests/Music_test.py 2009-01-11 03:12:02 +0000
511+++ entertainerlib/tests/test_music.py 2009-02-01 01:51:12 +0000
512@@ -4,9 +4,16 @@
513 __copyright__ = "2008, Matt Layman"
514 __author__ = "Matt Layman <laymansterms.dev@gmail.com>"
515
516+import os
517+
518 from pysqlite2 import dbapi2 as sqlite
519
520+from entertainerlib.frontend.medialibrary.music import (
521+ Album, AlbumHasNoTracks, MusicLibrary, Track, TrackRatingOutOfRange,
522+ TrackTypeError)
523+from entertainerlib.frontend.medialibrary.playable import Playable
524 from entertainerlib.tests import EntertainerTest
525+from entertainerlib.tests.helpers import MockBackendConnection
526
527 class TestMusic(EntertainerTest):
528 """This test class sets up the test database required for all test
529@@ -77,3 +84,370 @@
530 connection.commit()
531 connection.close()
532
533+
534+class TestTrack(TestMusic):
535+
536+ def setUp(self):
537+ TestMusic.setUp(self)
538+ self.track = Track('/path/to/track.mp3', # filename
539+ 'title',
540+ 1, # tracknumber
541+ 'artist0',
542+ 'album0',
543+ 'genre',
544+ '128', # bitrate
545+ 2008, # year
546+ 5, # rating
547+ 240, # length
548+ 'comment',
549+ 'lyrics')
550+
551+ def tearDown(self):
552+ TestMusic.tearDown(self)
553+
554+ def testTrackConstructor(self):
555+ """testTrackConstructor - Ensures that a Track object is created"""
556+ self.assertTrue(isinstance(self.track, Track))
557+
558+ def testTrackBadConstructor(self):
559+ """testTrackBadConstructor - Ensures that bad track construction
560+ raises an exception for the integer fields"""
561+ for i in [2, 7, 8, 9]:
562+ t = ['a', 'b', 1, 'c', 'd', 'e', 'f', 2, 3, 4, 'g', 'h']
563+ t[i] = str(t[i])
564+ self.assertRaises(TrackTypeError, Track, t[0], t[1], t[2], t[3],
565+ t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11])
566+
567+ def testTrackRatingInRange(self):
568+ """testTrackRatingInRange - Ensures that the ratings in range create
569+ valid Track objects"""
570+ for i in range(1, 6):
571+ self.track = Track('a', 'b', 1, 'c', 'd', 'e', 'f', 2, i, 3, 'g',
572+ 'h')
573+ self.assertTrue(isinstance(self.track, Track))
574+ self.assertEqual(self.track.get_rating(), i)
575+
576+ def testTrackRatingOutOfRange(self):
577+ """testTrackRatingOutOfRange - Ensures that the rating raises an
578+ exception for something out of range in construction"""
579+ for i in [0, 6]:
580+ self.assertRaises(TrackRatingOutOfRange, Track, 'a', 'b', 1, 'c',
581+ 'd', 'e', 'f', 2, i, 3, 'g', 'h')
582+
583+ def testTrackGetFilename(self):
584+ """testTrackGetFilename - Ensures that the filename is returned"""
585+ result = self.track.get_filename()
586+ self.assertEqual(result, '/path/to/track.mp3')
587+
588+ def testTrackGetTitle(self):
589+ """testTrackGetTitle - Ensures that the title is returned"""
590+ result = self.track.get_title()
591+ self.assertEqual(result, 'title')
592+
593+ def testTrackGetTrackNumber(self):
594+ """testTrackGetTrackNumber - Ensures that the tracknumber is
595+ returned"""
596+ result = self.track.get_tracknumber()
597+ self.assertEqual(result, 1)
598+
599+ def testTrackGetArtist(self):
600+ """testTrackGetArtist - Ensures that the artist is returned"""
601+ result = self.track.get_artist()
602+ self.assertEqual(result, 'artist0')
603+
604+ def testTrackGetAlbum(self):
605+ """testTrackGetAlbum - Ensures that an album object is returned"""
606+ result = self.track.get_album(self.cursor)
607+ self.assertTrue(isinstance(result, Album))
608+ self.assertEqual(result.get_title(), 'album0')
609+
610+ def testTrackGetAlbumNot(self):
611+ """testTrackGetAlbumNot - Ensures that a bad album in the track
612+ returns AlbumHasNoTracks"""
613+ self.badTrack = Track('path', 'title', 1, 'artist',
614+ 'foo-bar-baz**', # Here is the bad input
615+ 'genre', '128', 2008, 5, 240, 'comment',
616+ 'lyrics')
617+ self.assertRaises(AlbumHasNoTracks, self.badTrack.get_album,
618+ self.cursor)
619+
620+ def testTrackGetAlbumArtUrlExists(self):
621+ """testTrackGetAlbumArtUrl - Ensures that the album art url is
622+ returned"""
623+ album_artist = "artist0 - album0"
624+ album_artist = album_artist.encode("base64")
625+ album_art = os.path.join(self.art_path, album_artist + ".jpg")
626+ file = open(album_art, "wb")
627+ file.close()
628+ result = self.track.get_album_art_url(self.cursor)
629+ self.assertEqual(result, album_art)
630+ if os.path.exists(album_art):
631+ os.remove(album_art)
632+
633+ def testTrackGetAlbumArtUrlNotExists(self):
634+ """testTrackGetAlbumArtUrlNotExists - Ensures that when art does
635+ not exist, None is returned"""
636+ result = self.track.get_album_art_url(self.cursor)
637+ self.assertEqual(result, None)
638+
639+ def testTrackGetGenre(self):
640+ """testTrackGetGenre - Ensures that the genre is returned"""
641+ result = self.track.get_genre()
642+ self.assertEqual(result, 'genre')
643+
644+ def testTrackGetBitrate(self):
645+ """testTrackGetBitrate - Ensures that the bitrate is returned"""
646+ result = self.track.get_bitrate()
647+ self.assertEqual(result, '128')
648+
649+ def testTrackGetYear(self):
650+ """testTrackGetYear - Ensures that the year is returned"""
651+ result = self.track.get_year()
652+ self.assertEqual(result, 2008)
653+
654+ def testTrackGetRating(self):
655+ """testTrackGetRating - Ensures that the rating is returned"""
656+ result = self.track.get_rating()
657+ self.assertEqual(result, 5)
658+
659+ def testTrackGetLength(self):
660+ """testTrackGetLength - Ensures that the length is returned"""
661+ result = self.track.get_length()
662+ self.assertEqual(result, 240)
663+
664+ def testTrackGetComment(self):
665+ """testTrackGetComment - Ensures that the comment is returned"""
666+ result = self.track.get_comment()
667+ self.assertEqual(result, 'comment')
668+
669+ def testTrackGetLyrics(self):
670+ """testTrackGetLyrics - Ensures that the lyrics are returned"""
671+ result = self.track.get_lyrics()
672+ self.assertEqual(result, 'lyrics')
673+
674+ def testTrackSetLyrics(self):
675+ """testTrackSetLyrics - Ensures that lyrics are properly set"""
676+ self.track.set_lyrics('some new lyrics')
677+ self.assertEqual(self.track.get_lyrics(), 'some new lyrics')
678+
679+ def testTrackSetNoneLyrics(self):
680+ """testTrackSetNoneLyrics - Ensures that lyrics are set to empty
681+ string when None is passed as lyrics input"""
682+ self.track.set_lyrics(None)
683+ self.assertEqual(self.track.get_lyrics(), '')
684+
685+ def testTrackGetType(self):
686+ """testTrackGetType - Ensures that the type is returned"""
687+ result = self.track.get_type()
688+ self.assertEqual(result, Playable.AUDIO_STREAM)
689+
690+ def testTrackGetUri(self):
691+ """testTrackGetUri - Ensures that the uri is returned"""
692+ result = self.track.get_uri()
693+ self.assertEqual(result, 'file:///path/to/track.mp3')
694+
695+
696+class TestMusicLibrary(TestMusic):
697+ '''Tests MusicLibrary'''
698+
699+ def setUp(self):
700+ TestMusic.setUp(self)
701+ try:
702+ self.backend_connection = MockBackendConnection()
703+ except:
704+ print "\nbackend_connection failed"
705+ self.musiclibrary = MusicLibrary(self.backend_connection)
706+
707+ def tearDown(self):
708+ self.backend_connection.close_connection()
709+ TestMusic.tearDown(self)
710+
711+ def testMusicLibraryConstructor(self):
712+ """testMusicLibraryContructor - Ensures instantiation of MusicLibrary
713+ class"""
714+ self.assertTrue(isinstance(self.musiclibrary, MusicLibrary))
715+
716+ def testGetAllArtists(self):
717+ """testGetAllArtists - Ensures that all artists are returned from
718+ the music library"""
719+ result = self.musiclibrary.get_all_artists()
720+ self.assertEqual(result, ['artist0'])
721+
722+ def testGetAllTracks(self):
723+ """testGetAllTracks - Ensures that all tracks are returned"""
724+ result = self.musiclibrary.get_all_tracks()
725+ for i in result:
726+ self.assertTrue(isinstance(i, Track))
727+ self.assertEqual(len(result), 8)
728+
729+ def testGetTracksByGenre(self):
730+ """testGetTracksByGenre - Ensures tracks of a certain genre are
731+ returned"""
732+ result = self.musiclibrary.get_tracks_by_genre('genre0')
733+ self.assertEqual(len(result), 4)
734+ for i in result:
735+ self.assertEqual(i.get_genre(), 'genre0')
736+
737+ def testGetTracksByMissingGenre(self):
738+ """testGetTracksByMissingGenre - Ensures proper handling of a missing
739+ genre"""
740+ self.assertEquals(
741+ len(self.musiclibrary.get_tracks_by_genre('foo-bar-baz**')), 0)
742+
743+ def testGetTracksByArtist(self):
744+ """testGetTracksByArtist - Ensure tracks by a certain artist are
745+ returned"""
746+ result = self.musiclibrary.get_tracks_by_artist('artist0')
747+ self.assertEqual(len(result), 8)
748+ for i in result:
749+ self.assertEqual(i.get_artist(), 'artist0')
750+
751+ def testGetTracksByUnknownArtist(self):
752+ """testGetTracksByUnknownArtist - Ensure proper handling of an missing
753+ artist in the cache"""
754+ self.assertEquals(
755+ len(self.musiclibrary.get_tracks_by_artist('foo')), 0)
756+
757+ def testGetAllAlbums(self):
758+ """testGetAllAlbums - Ensures all albums are returned"""
759+ result = self.musiclibrary.get_all_albums()
760+ for i in result:
761+ self.assertTrue(isinstance(i, Album))
762+ self.assertEqual(len(result), 2)
763+
764+ def testGetAlbumsByArtist(self):
765+ """testGetAlbumsByArtist - Ensures correct albums by an artist is
766+ returned"""
767+ result = self.musiclibrary.get_albums_by_artist('artist0')
768+ self.assertEqual(len(result), 2)
769+ for i in result:
770+ self.assertEqual(i.get_artist(), 'artist0')
771+
772+ def testGetAlbumsByUnknownArtist(self):
773+ """testGetAlbumsByUnknownArtist - Ensures proper handling of an
774+ artist not in the cache"""
775+ self.assertEquals(
776+ len(self.musiclibrary.get_albums_by_artist('foo')), 0)
777+
778+ def testNumberOfTracks(self):
779+ """testNumberOfTracks - Ensures number of all tracks is returned"""
780+ result = self.musiclibrary.number_of_tracks()
781+ self.assertEqual(result, 8)
782+
783+ def testNumberOfTracksByArtist(self):
784+ """testNumberOfTracksByArtist - Ensures number of all tracks by one
785+ artist is returned"""
786+ result = self.musiclibrary.number_of_tracks_by_artist('artist0')
787+ self.assertEqual(result, 8)
788+
789+ def testNumberOfTracksByUnknownArtist(self):
790+ """testNumberOfTracksByUnknownArtist - Ensures proper handling when
791+ artist called is not in the cache"""
792+ self.assertEqual(
793+ self.musiclibrary.number_of_albums_by_artist('foo'), 0)
794+
795+ def testNumberOfAlbumsByArtist(self):
796+ """testNumberOfAlbumsByArtist - Ensures number of all albums by one
797+ artist is returned"""
798+ result = self.musiclibrary.number_of_albums_by_artist('artist0')
799+ self.assertEqual(result, 2)
800+
801+ def testNumberOfAlbumsByUnknownArtist(self):
802+ """testNumberOfAlbumsByUnknownArtist - Ensures proper handling when
803+ artist called is not in the cache"""
804+ self.assertEqual(
805+ self.musiclibrary.number_of_albums_by_artist('foo'), 0)
806+
807+ def testSaveLyrics(self):
808+ """testSaveLyrics - Ensures lyrics for a track are saved in the
809+ database"""
810+ # Only need a filename that matches something in the database, the rest
811+ # of the track is for construction purposes only
812+ self.track = Track('/filename/000', '', 0, '', '', '', '', 0, 1, 0, '',
813+ '')
814+ self.musiclibrary.save_lyrics(self.track, 'some lyrics here')
815+ self.assertEqual(self.track.get_lyrics(), 'some lyrics here')
816+
817+
818+class TestAlbum(TestMusic):
819+ '''Tests Album'''
820+
821+ def setUp(self):
822+ """See unittest.TestCase"""
823+ TestMusic.setUp(self)
824+ self.album = Album('album1', self.cursor)
825+
826+ def tearDown(self):
827+ """Clean up after the test"""
828+ TestMusic.tearDown(self)
829+
830+ def testAlbumConstructor(self):
831+ """Test that an Album object is properly constructed"""
832+ self.assertTrue(isinstance(self.album, Album))
833+
834+ def testAlbumConstructorNot(self):
835+ """Test that an AlbumHasNoTracks exception is raised when the created
836+ album doesn't exist in the cache"""
837+ self.assertRaises(AlbumHasNoTracks, Album, 'foo', self.cursor)
838+
839+ def testAlbumStr(self):
840+ """Test that title is returned in string conversion"""
841+ result = str(self.album)
842+ self.assertEqual(result, 'album1')
843+
844+ def testAlbumGetTitle(self):
845+ """Test that the album title is returned"""
846+ result = self.album.get_title()
847+ self.assertEqual(result, 'album1')
848+
849+ def testAlbumHasAlbumArt(self):
850+ """Test that album art exists for the file"""
851+ album_artist = "artist0 - album1"
852+ album_artist = album_artist.encode("base64")
853+ album_art = os.path.join(self.art_path, album_artist + ".jpg")
854+ file = open(album_art, "wb")
855+ file.close()
856+ self.assertTrue(self.album.has_album_art())
857+ if os.path.exists(album_art):
858+ os.remove(album_art)
859+
860+ def testAlbumHasAlbumArtNot(self):
861+ """Test that missing album art is reported back"""
862+ otherAlbum = Album('album1', self.cursor)
863+ self.assertFalse(otherAlbum.has_album_art())
864+
865+ def testAlbumGetAlbumArtUrl(self):
866+ """Test that the path to the album's art is returned"""
867+ result = self.album.get_album_art_url()
868+ album_artist = "artist0 - album1"
869+ album_artist = album_artist.encode("base64")
870+ album_art = os.path.join(self.art_path, album_artist + ".jpg")
871+ self.assertEqual(result, album_art)
872+
873+ def testAlbumGetTracks(self):
874+ """Test that all tracks for an album are returned"""
875+ result = self.album.get_tracks()
876+ self.assertEqual(len(result), 4)
877+ for i in result:
878+ self.assertTrue(isinstance(i, Track))
879+
880+ def testAlbumGetNumberOfTracks(self):
881+ """Test correct number of tracks from album is returned"""
882+ self.assertEqual(self.album.get_number_of_tracks(), 4)
883+
884+ def testAlbumGetYear(self):
885+ """Test that year of album is returned"""
886+ self.assertEqual(self.album.get_year(), 0)
887+
888+ def testAlbumGetGenre(self):
889+ """Test that genre of album is returned"""
890+ self.assertEqual(self.album.get_genre(), 'genre0')
891+
892+ def testAlbumGetArtist(self):
893+ """Test that artist of album is returned"""
894+ self.assertEqual(self.album.get_artist(), 'artist0')
895+
896+ def testAlbumGetTotalLength(self):
897+ """Test that total length of album is returned"""
898+ self.assertEqual(self.album.get_total_length(), 8)
899+
900
901=== renamed file 'entertainerlib/tests/OPMLParser_test.py' => 'entertainerlib/tests/test_opmlparser.py'
902=== renamed file 'entertainerlib/tests/Screen_test.py' => 'entertainerlib/tests/test_screen.py'
903=== renamed file 'entertainerlib/tests/ScrollArea_test.py' => 'entertainerlib/tests/test_scrollarea.py'
904=== renamed file 'entertainerlib/tests/SystemTrayMessageHandler_test.py' => 'entertainerlib/tests/test_systemtraymessagehandler.py'
905=== renamed file 'entertainerlib/tests/Texture_test.py' => 'entertainerlib/tests/test_texture.py'
906=== renamed file 'entertainerlib/tests/Theme_test.py' => 'entertainerlib/tests/test_theme.py'
907=== renamed file 'entertainerlib/tests/Thumbnailer_test.py' => 'entertainerlib/tests/test_thumbnailer.py'
908=== renamed file 'entertainerlib/tests/TransitionFactory_test.py' => 'entertainerlib/tests/test_transitionfactory.py'
909=== renamed file 'entertainerlib/tests/VideoMetadataSearch_test.py' => 'entertainerlib/tests/test_videometadatasearch.py'
910=== renamed file 'entertainerlib/tests/VideoThumbnailer_test.py' => 'entertainerlib/tests/test_videothumbnailer.py'
911=== renamed file 'entertainerlib/tests/Weather_test.py' => 'entertainerlib/tests/test_weather.py'
912=== removed file 'run_tests.py'
913--- run_tests.py 2009-01-11 20:10:22 +0000
914+++ run_tests.py 1970-01-01 00:00:00 +0000
915@@ -1,54 +0,0 @@
916-#!/usr/bin/env python
917-'''Entertainer test runner'''
918-
919-import os
920-import shutil
921-import sys
922-import unittest
923-
924-from entertainerlib.frontend.translation_setup import TranslationSetup
925-
926-TOP_LEVEL_DIR = os.path.abspath('.')
927-
928-IGNORE_FILES = []
929-
930-TranslationSetup()
931-
932-suite = unittest.TestSuite()
933-debug = False
934-
935-try:
936- descriptions = sys.argv[1]
937- verbosity = sys.argv[1]
938-except IndexError:
939- descriptions = 0
940- verbosity = 0
941-
942-try:
943- if sys.argv[2] == '1':
944- debug = True
945-except IndexError:
946- pass
947-
948-# Clean up the cfg_dir between runs
949-test_cfg = '/tmp/cfg_dir'
950-if os.path.exists(test_cfg):
951- shutil.rmtree(test_cfg)
952-
953-for file in os.listdir(TOP_LEVEL_DIR + '/entertainerlib/tests/'):
954- if file in IGNORE_FILES:
955- continue
956- if file[-8:] != '_test.py':
957- continue
958- import_name = 'entertainerlib.tests.' + file[:-3]
959- if debug:
960- print 'Found test : %s' % import_name
961- suite.addTest(
962- unittest.defaultTestLoader.loadTestsFromName(import_name)
963- )
964-
965-test_runner = unittest.TextTestRunner(descriptions=descriptions,
966- verbosity=verbosity)
967-result = test_runner.run(suite)
968-if result.failures or result.errors:
969- sys.exit(1)

Subscribers

People subscribed via source and target branches