-
Notifications
You must be signed in to change notification settings - Fork 9
/
tests.py
96 lines (74 loc) · 3.15 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import os
from itunesLibrary import library
SAMPLE_DATA_DIRECTORY = "./sample-data/"
def test_empty():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"empty.xml"))
assert 0 == len(lib)
def test_applicationVersion():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"empty.xml"))
assert "11.0.2" == lib.applicationVersion
def test_minorVersion():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"empty.xml"))
assert "1" == lib.minorVersion
def test_majorVersion():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"empty.xml"))
assert "2" == lib.majorVersion
def test_playlists():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.playlists
def test_library_items():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.items
def test_playlist_items():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.playlists[0].items
def test_iter():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.__iter__()
def test_playlist_iter():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.__iter__().__iter__()
def test_length():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert 10 == len(lib)
def test_artist():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert "David Bowie" == lib.items[0].artist
def test_album():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert "The Next Day (Deluxe Version)" == lib.items[0].album
def test_title():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert "The Next Day" == lib.items[0].title
def test_getItemsForArtist():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
assert lib.getItemsForArtist("David Bowie")
def test_getItemsForArtist_Failure():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
items = lib.getItemsForArtist("Not There")
assert items == []
def test_getItemsById():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
item = lib.getItemsById("16116")
assert item.album == 'The Next Day (Deluxe Version)' and item.getItunesAttribute('Total Time') == '178474'
def test_totalTime():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
item = lib.getItemsById("16116")
assert item.getItunesAttribute('Total Time') == '178474'
def test_getItemsById_Failure():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
item = lib.getItemsById("-1")
assert not item
def test_getItemsById_Integer():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"10.xml"))
item = lib.getItemsById(16116)
assert item
def test_playlist():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"111.xml"))
playlist = lib.getPlaylist("Gray")
assert len(playlist) # it has items
def test_unicode_title():
lib = library.parse(os.path.join(SAMPLE_DATA_DIRECTORY,"unicode.xml"))
item = lib.getItemsById("164")
assert item.title
assert item.artist == 'Blackfield'