-
Notifications
You must be signed in to change notification settings - Fork 40
/
test.py
47 lines (40 loc) · 9.4 KB
/
test.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
import unittest
from Download import *
import json
actualAlbumJson = {
"albumId": "2859116",
"albumJsonString": '{"title":"Dharmadurai","name":"Dharmadurai","year":"2016","release_date":"2016-08-12","primary_artists":"Yuvan Shankar Raja","primary_artists_id":"456091","albumid":"2859116","perma_url":"https:\/\/www.saavn.com\/p\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","songs":[{"id":"S5gUQ69N","type":"","song":"Endha Pakkam","album":"Dharmadurai","year":"2016","music":"Yuvan Shankar Raja","music_id":"456091","primary_artists":"Rahul Nambiar, Chinmayi Sripaada","primary_artists_id":"455334, 1984879","featured_artists":"","featured_artists_id":"","singers":"Rahul Nambiar, Chinmayi Sripaada","starring":"Vijay Sethupathi, Tamannaah Bhatia, Aishwarya Rajesh, Srushti Dange, Raadhika Sarathkumar","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","label":"TrendMusic","albumid":"2859116","language":"tamil","origin":"album","play_count":"110005","320kbps":"true","explicit_content":0,"has_lyrics":"false","encrypted_media_url":"ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDy8hgFzmhPkiLNrtIq6at0VlPKdZtw8DnDYGIVgZBKZ+PpErB1FHUwoxw7tS9a8Gtq","encrypted_media_path":"NMKyboFo\/FgEvCykYIb4hRuc4W1nxMFxgPhSFTgSyJwhkHAegtI8+A==","perma_url":"https:\/\/www.saavn.com\/s\/song\/tamil\/Dharmadurai\/Endha-Pakkam\/I10MZCUGDn0","album_url":"https:\/\/www.saavn.com\/s\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","duration":"303","rights":{"code":0,"reason":"","cacheable":true},"starred":"false","artistMap":{"Yuvan Shankar Raja":"456091","Rahul Nambiar":"455334","Chinmayi Sripaada":"1984879","Vairamuthu":"457542","Vijay Sethupathi":"678644","Tamannaah Bhatia":"486697","Aishwarya Rajesh":"1393839","Srushti Dange":"843933","Raadhika Sarathkumar":"674948"},"hashtags":[]},{"id":"vpm2GELL","type":"","song":"Aandipatti","album":"Dharmadurai","year":"2016","music":"Yuvan Shankar Raja","music_id":"456091","primary_artists":"Senthil Das, Surmukhi","primary_artists_id":"456444, 460156","featured_artists":"","featured_artists_id":"","singers":"Senthil Das, Surmukhi","starring":"Vijay Sethupathi, Tamannaah Bhatia, Aishwarya Rajesh, Srushti Dange, Raadhika Sarathkumar","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","label":"TrendMusic","albumid":"2859116","language":"tamil","origin":"album","play_count":"160417","320kbps":"true","explicit_content":0,"has_lyrics":"false","encrypted_media_url":"ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyPwgfoo+kYe4jQ\/M\/eMJJ2yEPnNejqNiVxAKwNRV91Tb0b43iuHkSBRw7tS9a8Gtq","encrypted_media_path":"NMKyboFo\/FgEvCykYIb4hRuc4W1nxMFxgPhSFTgSyJycLZaDXGff0w==","perma_url":"https:\/\/www.saavn.com\/s\/song\/tamil\/Dharmadurai\/Aandipatti\/BhgGAzN1e38","album_url":"https:\/\/www.saavn.com\/s\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","duration":"279","rights":{"code":0,"reason":"","cacheable":true},"starred":"false","artistMap":{"Yuvan Shankar Raja":"456091","Senthil Das":"456444","Surmukhi":"460156","Vairamuthu":"457542","Vijay Sethupathi":"678644","Tamannaah Bhatia":"486697","Aishwarya Rajesh":"1393839","Srushti Dange":"843933","Raadhika Sarathkumar":"674948"},"hashtags":[]},{"id":"DmdC4DRl","type":"","song":"Poi Vaada","album":"Dharmadurai","year":"2016","music":"Yuvan Shankar Raja","music_id":"456091","primary_artists":"Srimathumitha","primary_artists_id":"459923","featured_artists":"","featured_artists_id":"","singers":"Srimathumitha","starring":"Vijay Sethupathi, Tamannaah Bhatia, Aishwarya Rajesh, Srushti Dange, Raadhika Sarathkumar","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","label":"TrendMusic","albumid":"2859116","language":"tamil","origin":"album","play_count":"59136","320kbps":"true","explicit_content":0,"has_lyrics":"false","encrypted_media_url":"ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyFHdM0uf7ukbglVn5O4VeKVYBivlatFY7QkAEk0WQCsebiOERm\/E3sxw7tS9a8Gtq","encrypted_media_path":"NMKyboFo\/FgEvCykYIb4hRuc4W1nxMFxgPhSFTgSyJy2Z\/EIrlqhYw==","perma_url":"https:\/\/www.saavn.com\/s\/song\/tamil\/Dharmadurai\/Poi-Vaada\/NAUPckB0ZV8","album_url":"https:\/\/www.saavn.com\/s\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","duration":"124","rights":{"code":0,"reason":"","cacheable":true},"starred":"false","artistMap":{"Yuvan Shankar Raja":"456091","Srimathumitha":"459923","Vairamuthu":"457542","Vijay Sethupathi":"678644","Tamannaah Bhatia":"486697","Aishwarya Rajesh":"1393839","Srushti Dange":"843933","Raadhika Sarathkumar":"674948"},"hashtags":[]},{"id":"D2L4MncP","type":"","song":"Makka Kalanguthappa","album":"Dharmadurai","year":"2016","music":"Yuvan Shankar Raja","music_id":"456091","primary_artists":"Mathichiyam Bala","primary_artists_id":"2329970","featured_artists":"","featured_artists_id":"","singers":"Mathichiyam Bala","starring":"Vijay Sethupathi, Tamannaah Bhatia, Aishwarya Rajesh, Srushti Dange, Raadhika Sarathkumar","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","label":"TrendMusic","albumid":"2859116","language":"tamil","origin":"album","play_count":"131191","320kbps":"true","explicit_content":0,"has_lyrics":"false","encrypted_media_url":"ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyCg93dHcR7nak4IF8Y7q55RrLT1Zl40yylprtGOY9XO3kDDjJpvJ5lBw7tS9a8Gtq","encrypted_media_path":"NMKyboFo\/FgEvCykYIb4hRuc4W1nxMFxgPhSFTgSyJx2N6f1118VLw==","perma_url":"https:\/\/www.saavn.com\/s\/song\/tamil\/Dharmadurai\/Makka-Kalanguthappa\/NFonBTleVGM","album_url":"https:\/\/www.saavn.com\/s\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","duration":"246","rights":{"code":0,"reason":"","cacheable":true},"starred":"false","artistMap":{"Yuvan Shankar Raja":"456091","Mathichiyam Bala":"2329970","Vairamuthu":"457542","Vijay Sethupathi":"678644","Tamannaah Bhatia":"486697","Aishwarya Rajesh":"1393839","Srushti Dange":"843933","Raadhika Sarathkumar":"674948"},"hashtags":[]},{"id":"G8S82Lhc","type":"","song":"Naan Kaatrilae","album":"Dharmadurai","year":"2016","music":"Yuvan Shankar Raja","music_id":"456091","primary_artists":"Karthik","primary_artists_id":"455240","featured_artists":"","featured_artists_id":"","singers":"Karthik","starring":"Vijay Sethupathi, Tamannaah Bhatia, Aishwarya Rajesh, Srushti Dange, Raadhika Sarathkumar","image":"https:\/\/c.saavncdn.com\/541\/Dharmadurai-Tamil-2016-150x150.jpg","label":"TrendMusic","albumid":"2859116","language":"tamil","origin":"album","play_count":"58511","320kbps":"true","explicit_content":0,"has_lyrics":"false","encrypted_media_url":"ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyT0VRImYxzvRy+BopogF3HzzizzaWEi9pSjsU49zxpy5IdoJhMsu2ghw7tS9a8Gtq","encrypted_media_path":"NMKyboFo\/FgEvCykYIb4hRuc4W1nxMFxgPhSFTgSyJy4E2eGPoH1sQ==","perma_url":"https:\/\/www.saavn.com\/s\/song\/tamil\/Dharmadurai\/Naan-Kaatrilae\/N1A4CUZ8X1A","album_url":"https:\/\/www.saavn.com\/s\/album\/tamil\/Dharmadurai-2016\/9jeVLoY0YaY_","duration":"214","rights":{"code":0,"reason":"","cacheable":true},"starred":"false","artistMap":{"Yuvan Shankar Raja":"456091","Karthik":"455240","Vairamuthu":"457542","Vijay Sethupathi":"678644","Tamannaah Bhatia":"486697","Aishwarya Rajesh":"1393839","Srushti Dange":"843933","Raadhika Sarathkumar":"674948"},"hashtags":[]}]}'}
meta = {'id': 'gEQ579US', 'type': '', 'song': 'Life Of Raghuvaran - Nada Da Raja',
'album': 'Velai Illa Pattadhaari 2',
'year': '2017', 'music': 'Sean Roldan', 'music_id': '718103', 'primary_artists': 'Dhanush, Yogi B',
'primary_artists_id': '455662, 483099', 'featured_artists': '', 'featured_artists_id': '',
'singers': 'Dhanush, Yogi B', 'starring': 'Dhanush, Kajol, Samuthirakani, Amala Paul, Saranya',
'image': 'http://c.saavncdn.com/007/Velai-Illa-Pattadhaari-2-Tamil-2017-150x150.jpg', 'label': 'Divo',
'albumid': '11056599', 'language': 'tamil', 'origin': 'album', 'play_count': '94030', '320kbps': 'true',
'explicit_content': 0, 'has_lyrics': 'false',
'encrypted_media_url': 'ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyDuB/PB/4c2vbQkAJnkSzN30TPPRkFKwr46HYXaJAkyWa1/xeAiAm1xw7tS9a8Gtq',
'encrypted_media_path': 'NMKyboFo/Fi5qGL/WLXvK7Z9yTakFwkuwm8V1hgRQkkYFOzGrFvJ/w==',
'perma_url': 'https://www.saavn.com/s/song/tamil/Velai-Illa-Pattadhaari-2/Life-Of-Raghuvaran---Nada-Da-Raja/Fy06BEMJYmA',
'album_url': 'https://www.saavn.com/s/album/tamil/Velai-Illa-Pattadhaari-2-2017/uNaPsRjpu-E_',
'duration': '210', 'rights': {'code': 0, 'reason': '', 'cacheable': True}, 'starred': 'false',
'artistMap': {'Sean Roldan': '718103', 'Dhanush': '455662', 'Yogi B': '483099', 'Kajol': '459640',
'Samuthirakani': '480576', 'Amala Paul': '463563', 'Saranya': '458960'}, 'hashtags': []}
#addtags('Life Of Raghuvaran - Nada Da Raja.m4a', meta)
class TestStringMethods(unittest.TestCase):
def test_album_json(self):
self.maxDiff = None
albumJson = json.loads(actualAlbumJson['albumJsonString'])
self.assertIsInstance(getAlbum(actualAlbumJson['albumId']), list, 'First argument is not a list')
self.assertIsInstance(albumJson['songs'], list, 'Second argument is not a list')
self.assertListEqual(getAlbum(actualAlbumJson['albumId']), albumJson['songs'])
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()