├── .gitignore ├── README.md ├── __init__.py ├── clean.sh ├── lib ├── __init__.py ├── artists.py ├── factory.py ├── genres.py ├── metrics.py ├── profiles.py ├── resource.py └── services.py ├── nbs_api.py ├── tests.py └── tests ├── __init__.py ├── tests_json.py └── tests_xml.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store 3 | *~ 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Python Wrapper for the Next Big Sound API 2 | 10/27/2011 3 | 4 | ##Contributors: 5 | 6 | - Buck Heroux 7 | - Sean Smith 8 | - James B. Fitzgerald 9 | - Omar Sulehria 10 | - Charles McClung 11 | - Michael Odbert 12 | 13 | ##Conventions 14 | - Use 2 spaces for indentation 15 | 16 | ## artists.py 17 | 18 | def view(self, id): 19 | return self.get(self.genUrl( )+"/"+id, "") 20 | 21 | > *id* is the artists id ex: Kanye West = 356 22 | 23 | def search(self, query): 24 | return self.get(self.genUrl( ), {'q':query}) 25 | 26 | > *query* is the artist's name 27 | 28 | def rank(self, type, ids): 29 | ids = "" 30 | for i in ids: 31 | uids += str(i) + '-' 32 | uids = uids\[:-1]\ 33 | return self.get(self.genUrl( ) + "/" + type + "/" + uids, "") 34 | 35 | > *type* is either nominal/velocity/acceleration 36 | > *ids* is a list of artist id ex: \[356, 357, 358\] 37 | 38 | def add(self, name, profiles): 39 | data = {} 40 | data\['name'\] = name 41 | data\['profiles\[\]'\] = '&&'.join(profiles) 42 | data\['key'\] = self.secret 43 | return self.post(self.genUrl( ), data) 44 | 45 | > *name* is the name of the artist you want to add 46 | > *profiles* is a list of profile urls ex: \["http://www.facebook.com/kanyewest", "http://www.myspace.com/kanyewest"\] 47 | 48 | ## genres.py 49 | 50 | def artist(self, id): 51 | return self.get(self.genUrl( )+"/"+id, "") 52 | 53 | > *id* is the artist id 54 | 55 | ## metrics.py 56 | 57 | def profile(self, id, opt=[]): 58 | if opt == []: 59 | return self.get(self.genUrl( )+"/"+id, "") 60 | else: 61 | data = {} 62 | data\['start'\] = opt\[0\] 63 | data\['end'\] = opt\[1\] 64 | data\['metric'\] = opt\[2\] 65 | return self.post(self.genUrl( )+"/"+id, data)* 66 | 67 | > Tricky thing here is that there's optional post parameters. 68 | > ie: opt is defaulted to an empty list 69 | > 70 | > If there are not optional post parameters for metrics than 71 | > just get the metrics of a profile with id *id* 72 | > 73 | > If there are option parameters then we need to post them. 74 | > You need to checkout the documentation on python urrlib for 75 | > how the mapping works from variable name to value 76 | 77 | def artist(self, id, opt=\[\]): 78 | if opt == \[\]: 79 | return self.get(self.genUrl( )+"/"+id, "") 80 | else: 81 | data = {} 82 | data\['start'\] = opt\[0\] 83 | data\['end'\] = opt\[1\] 84 | data\['metric'\] = opt\[2\] 85 | return self.post(self.genUrl( )+"/"+id, data) 86 | 87 | > Tricky thing here is that there's optional post parameters. 88 | > ie: opt is defaulted to an empty list 89 | > 90 | > If there are not optional post parameters for metrics than 91 | > just get the metrics of a profile with id *id* 92 | > 93 | > If there are option parameters then we need to post them. 94 | > You need to checkout the documentation on python urrlib for 95 | > how the mapping works from variable name to value 96 | 97 | ## profiles.py 98 | 99 | def artist(self, id): 100 | return self.get(self.genUrl( )+"/"+id, "") 101 | 102 | > *id* is the artist id 103 | 104 | def search(self, url): 105 | return self.get(self.genUrl( ), {'u':url}) 106 | 107 | > *url* is the profiles url ex: http://www.myspace.com 108 | 109 | def add(self, id, profiles): 110 | data = {} 111 | data\['profiles\[\]'\] = '&&'.join(profiles) 112 | data\['key'\] = self.secret 113 | return self.post(self.genUrl( )+"/"+id, data) 114 | 115 | > *id* is the artist id 116 | > 117 | > *profiles* is a list of profile urls to add to this artist's profile 118 | 119 | ## services.py 120 | 121 | def list(self): 122 | return self.get(self.genUrl( )\[:-5\], "") 123 | 124 | > Retrieve all the social media sites that we support 125 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buckhx/NBS-API-Python/412b8bd660f17ce68acb35a499322059088c7a53/__init__.py -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #Cleans all *.pyc from project 2 | # Note: Only works on unix 3 | 4 | find . -name "*.pyc" -exec rm -rf {} \; 5 | -------------------------------------------------------------------------------- /lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buckhx/NBS-API-Python/412b8bd660f17ce68acb35a499322059088c7a53/lib/__init__.py -------------------------------------------------------------------------------- /lib/artists.py: -------------------------------------------------------------------------------- 1 | from resource import Resource 2 | 3 | class Artists(Resource): 4 | 5 | def view(self, id): 6 | return self.get(self.genUrl( )+"/"+id, "") 7 | 8 | def search(self, query): 9 | return self.get(self.genUrl( ), {'q':query}) 10 | 11 | def rank(self, type, ids): 12 | uids = "" 13 | for i in ids: 14 | uids += str(i) + '-' 15 | uids = uids[:-1] 16 | return self.get(self.genUrl( ) + "/" + type + "/" + uids, "") 17 | 18 | def add(self, name, profiles): 19 | if (self.secret == ""): 20 | raise Exception("A private key is needed") 21 | else: 22 | data = {} 23 | data['name'] = name 24 | data['profiles[]'] = '&&'.join(profiles) 25 | data['key'] = self.secret 26 | return self.post(self.genUrl( ), data) 27 | 28 | -------------------------------------------------------------------------------- /lib/factory.py: -------------------------------------------------------------------------------- 1 | from artists import Artists 2 | from genres import Genres 3 | from metrics import Metrics 4 | from profiles import Profiles 5 | from services import Services 6 | 7 | class ResourceFactory: 8 | 9 | def __init__(self, key, secret, ext): 10 | self.key = key 11 | self.secret = secret 12 | self.ext = ext 13 | 14 | def setKey(self, key): 15 | self.key = key 16 | 17 | def getKey(self): 18 | return self.key 19 | 20 | def setSecret(self, secret): 21 | self.secret = secret 22 | 23 | def getSecret(self): 24 | return self.secret 25 | 26 | def setExt(self, ext): 27 | self.ext = ext 28 | 29 | def getExt(self): 30 | return self.ext 31 | 32 | def getArtists(self): 33 | return Artists(self.key, self.secret, self.ext) 34 | 35 | def getGenres(self): 36 | return Genres(self.key, self.secret, self.ext) 37 | 38 | def getMetrics(self): 39 | return Metrics(self.key, self.secret, self.ext) 40 | 41 | def getProfiles(self): 42 | return Profiles(self.key, self.secret, self.ext) 43 | 44 | def getServices(self): 45 | return Services(self.key, self.secret, self.ext) 46 | -------------------------------------------------------------------------------- /lib/genres.py: -------------------------------------------------------------------------------- 1 | from resource import Resource 2 | 3 | class Genres(Resource): 4 | 5 | def artist(self, id): 6 | return self.get(self.genUrl( )+"/"+id, "") 7 | 8 | -------------------------------------------------------------------------------- /lib/metrics.py: -------------------------------------------------------------------------------- 1 | from resource import Resource 2 | 3 | class Metrics(Resource): 4 | 5 | def profile(self, id, opt=[]): 6 | if opt == []: 7 | # print repr(self.get(self.genUrl( )+"/"+id, "")) 8 | return self.get(self.genUrl( )+"/"+id, "") 9 | else: 10 | data = {} 11 | data['start'] = opt[0] 12 | data['end'] = opt[1] 13 | data['metric'] = opt[2] 14 | return self.post(self.genUrl( )+"/"+id, data) 15 | 16 | def artist(self, id, opt=[]): 17 | if opt == []: 18 | return self.get(self.genUrl( )+"/"+id, "") 19 | else: 20 | data = {} 21 | data['start'] = opt[0] 22 | data['end'] = opt[1] 23 | data['metric'] = opt[2] 24 | return self.post(self.genUrl( )+"/"+id, data) 25 | -------------------------------------------------------------------------------- /lib/profiles.py: -------------------------------------------------------------------------------- 1 | from resource import Resource 2 | 3 | class Profiles(Resource): 4 | 5 | def artist(self, id): 6 | return self.get(self.genUrl( )+"/"+id, "") 7 | 8 | def search(self, url): 9 | return self.get(self.genUrl( ), {'u':url}) 10 | 11 | def add(self, id, profiles): 12 | if (self.secret == ""): 13 | raise Exception("A private key is needed") 14 | else: 15 | data = {} 16 | data['profiles[]'] = '&&'.join(profiles) 17 | data['key'] = self.secret 18 | return self.post(self.genUrl( )+"/"+id, data) 19 | -------------------------------------------------------------------------------- /lib/resource.py: -------------------------------------------------------------------------------- 1 | import urllib as rest 2 | import inspect 3 | 4 | class Resource: 5 | base = ".api3.nextbigsound.com/" 6 | 7 | # Constructor: 8 | def __init__(self, key, secret, ext): 9 | self.key = key 10 | self.secret = secret 11 | self.ext = ext 12 | 13 | # HTTP GET 14 | def get(self,url,params): 15 | if params == "": 16 | q = "" 17 | else: 18 | q = "?" 19 | url = url + self.ext + q + rest.urlencode(params) 20 | #print repr(rest.urlopen(url).geturl( )) 21 | return rest.urlopen(url).read() 22 | 23 | # HTTP POST 24 | def post(self,url,data): 25 | url = url + self.ext 26 | data = rest.urlencode(data) 27 | # print repr(data) 28 | # print repr(rest.urlopen(url,data).geturl( )) 29 | return rest.urlopen(url,data).read() 30 | 31 | # generates url based on method called and resource used 32 | # takes the resource and method name EXACTLY as defined 33 | # Sean: Sometimes we do not want the generated url to end 34 | # in a '/' because we may just want it to end in .json 35 | # or .xml with the possibility of GET or POST variables 36 | # I chose to make the trailing '/' dependent on the 37 | # calling Resource rather than this function. 38 | def genUrl(self): 39 | resource = self.__class__.__name__ 40 | method = inspect.stack()[1][3] 41 | return ("http://" + self.key + Resource.base + resource + "/" + method).lower() 42 | 43 | -------------------------------------------------------------------------------- /lib/services.py: -------------------------------------------------------------------------------- 1 | from resource import Resource 2 | 3 | class Services(Resource): 4 | 5 | def list(self): 6 | return self.get(self.genUrl( )[:-5], "") 7 | -------------------------------------------------------------------------------- /nbs_api.py: -------------------------------------------------------------------------------- 1 | from lib.factory import ResourceFactory 2 | 3 | class API: 4 | 5 | def __init__(self, key, secret="", ext=".json"): 6 | self.factory = ResourceFactory(key, secret, ext) 7 | 8 | def setKey(self, key): 9 | self.factory.setKey(key) 10 | 11 | def getKey(self): 12 | return self.factory.getKey( ) 13 | 14 | def setSecret(self, secret): 15 | self.factory.setSecret( ) 16 | 17 | def getSecret(self): 18 | return self.factory.getSecret( ) 19 | 20 | def setExt(self, ext): 21 | self.factory.setExt(ext) 22 | 23 | def getExt(self): 24 | return self.factory.getExt( ) 25 | 26 | def artist(self): 27 | return self.factory.getArtists( ) 28 | 29 | def artistView(self,id): 30 | return self.artist().view(id) 31 | 32 | def artistSearch(self,name): 33 | return self.artist( ).search(name) 34 | 35 | def artistRanking(self,type,ids): 36 | return self.artist().rank(type,ids) 37 | 38 | def artistAdd(self,name, profiles): 39 | return self.artist().add(name, profiles) 40 | 41 | def genres(self): 42 | return self.factory.getGenres() 43 | 44 | def genresArtist(self,id): 45 | return self.genres().artist(id) 46 | 47 | def metrics(self): 48 | return self.factory.getMetrics() 49 | 50 | def metricsProfile(self, id, opt=[]): 51 | return self.metrics().profile(id, opt) 52 | 53 | def metricsArtist(self, id, opt=[]): 54 | return self.metrics().artist(id, opt) 55 | 56 | def profiles(self): 57 | return self.factory.getProfiles() 58 | 59 | def profilesArtist(self, id): 60 | return self.profiles().artist(id) 61 | 62 | def profilesSearch(self, url): 63 | return self.profiles().search(url) 64 | 65 | def profilesAdd(self, id, profiles): 66 | return self.profiles().add(id, profiles) 67 | 68 | def services(self): 69 | return self.factory.getServices() 70 | 71 | def servicesList(self): 72 | return self.services().list() 73 | 74 | -------------------------------------------------------------------------------- /tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import tests.tests_json as json 4 | import tests.tests_xml as xml 5 | 6 | def run( ): 7 | print "*********[RUNNING TESTS]*********" 8 | print ">> JSON tests first because it's cool" 9 | json.run( ) 10 | print ">> XML tests second because..." 11 | xml.run( ) 12 | passed = json.passed + xml.passed 13 | total = json.total + xml.total 14 | print "*********[FINISHED TESTS]*********" 15 | print ">> RESULTS:" 16 | print ">> "+str(passed)+"/"+str(total)+" passed" 17 | if (passed < total): 18 | print ">> FAILURES:" 19 | failures = json.failed + xml.failed 20 | for f in failures: 21 | print ">> "+f 22 | 23 | 24 | print ">>" 25 | print ">>" 26 | print ">> Hopefully you didn't break anything..." 27 | print ">> I know who you are if you did" 28 | 29 | run( ) 30 | 31 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/buckhx/NBS-API-Python/412b8bd660f17ce68acb35a499322059088c7a53/tests/__init__.py -------------------------------------------------------------------------------- /tests/tests_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from nbs_api import API 4 | import json 5 | 6 | failed = [""] 7 | passed = 0 8 | total = 11 9 | 10 | def artist_view_test(): 11 | global failed 12 | global passed 13 | api = API("nbsmobile") 14 | resp = json.loads(api.artistView("356")) 15 | if resp["music_brainz_id"] == "164f0d73-1234-4e2c-8743-d77bf2191051": 16 | passed += 1 17 | else: 18 | failed += ["artist_view_test_( )"] 19 | 20 | def artist_search_test(): 21 | global failed 22 | global passed 23 | api = API("nbsmobile"); 24 | resp = json.loads(api.artistSearch("Kanye")) 25 | if resp["356"]["music_brainz_id"] == "164f0d73-1234-4e2c-8743-d77bf2191051": 26 | passed += 1 27 | else: 28 | failed += ["artist_search_test( )"] 29 | 30 | def artist_ranking_test(): 31 | global failed 32 | global passed 33 | api = API("nbsmobile") 34 | ids = [356, 659, 8309] 35 | type = "nominal" 36 | resp = json.loads(api.artistRanking(type, ids)) 37 | if (resp[0]["name"] == "Lady Gaga"): 38 | passed += 1 39 | else: 40 | failed += ["artist_ranking_test( )"] 41 | 42 | def artist_add_test(): 43 | global failed 44 | global passed 45 | api = API("nbsmobile", "ad644d582c7dcf7dc29479ff2d4df1ef") 46 | name = "Long Miles" 47 | profiles = ["http://www.facebook.com/longmiles"] 48 | resp = json.loads(api.artistAdd(name, profiles)) 49 | if resp['message'] == "That Artist already exists in our system [#324157]": 50 | passed += 1 51 | else: 52 | failed += ["artist_add_test( )"] 53 | 54 | def genres_artist_test(): 55 | global failed 56 | global passed 57 | api = API("nbsmobile") 58 | resp = json.loads(api.genresArtist("356")) 59 | if resp["2"]["name"] == "HipHop": 60 | passed += 1 61 | else: 62 | failed += ["genres_artist_test( )"] 63 | 64 | def metrics_profile_test(): 65 | global failed 66 | global passed 67 | api = API("nbsmobile") 68 | resp = json.loads(api.metricsProfile("388")) 69 | if resp["plays"] and resp["fans"] and resp["views"]: 70 | passed += 1 71 | else: 72 | failed += ["metrics_profile_test( )"] 73 | 74 | def metrics_artist_test(): 75 | global failed 76 | global passed 77 | api = API("nbsmobile") 78 | resp = json.loads(api.metricsArtist("356")) 79 | if resp[0]["Service"]["name"] == "MySpace": 80 | passed += 1 81 | else: 82 | failed += ["metrics_artist_test( )"] 83 | 84 | def profiles_artist_test(): 85 | global failed 86 | global passed 87 | api = API("nbsmobile") 88 | resp = json.loads(api.profilesArtist("356")) 89 | if resp["388"]["name"] == "MySpace": 90 | passed += 1 91 | else: 92 | failed += ["profiles_artist_test( )"] 93 | 94 | def profiles_search_test(): 95 | global failed 96 | global passed 97 | api = API("nbsmobile"); 98 | resp = json.loads(api.profilesSearch("http://www.myspace.com/kanyewest")) 99 | if resp["356"]["music_brainz_id"] == "164f0d73-1234-4e2c-8743-d77bf2191051": 100 | passed += 1 101 | else: 102 | failed += ["profiles_search_test( )"] 103 | 104 | def profiles_add_test(): 105 | global failed 106 | global passed 107 | api = API("nbsmobile", "ad644d582c7dcf7dc29479ff2d4df1ef") 108 | name = "Long Miles" 109 | profiles = ["http://www.myspace.com/longmiles"] 110 | resp = json.loads(api.profilesAdd("324157", profiles)) 111 | if resp['name'] == "Long Miles": 112 | passed += 1 113 | else: 114 | failed += ["artist_add_test( )"] 115 | 116 | def services_list_test(): 117 | global failed 118 | global passed 119 | api = API("nbsmobile") 120 | resp = json.loads(api.servicesList()) 121 | if resp["1"]["name"] == "MYSPACE" and resp["36"]["name"] == "PANDORA": 122 | passed += 1 123 | else: 124 | failed += ["artist_add_test( )"] 125 | 126 | def run( ): 127 | print ">> Running JSON Tests..." 128 | artist_view_test() 129 | artist_search_test() 130 | artist_ranking_test() 131 | artist_add_test() 132 | genres_artist_test() 133 | metrics_profile_test() 134 | metrics_artist_test() 135 | profiles_artist_test() 136 | profiles_search_test() 137 | profiles_add_test() 138 | services_list_test() 139 | print ">> JSON Tests finished" 140 | -------------------------------------------------------------------------------- /tests/tests_xml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from nbs_api import API 4 | import xml.dom.minidom 5 | 6 | failed = [] 7 | passed = 0 8 | total = 11 9 | 10 | def artist_view_test(): 11 | global failed 12 | global passed 13 | api = API("nbsmobile", "", ".xml") 14 | resp = xml.dom.minidom.parseString(api.artistView("356")) 15 | music_id = resp.getElementsByTagName("music_brainz_id")[0].childNodes[0].data 16 | if(music_id == "164f0d73-1234-4e2c-8743-d77bf2191051"): 17 | passed += 1 18 | else: 19 | failed.append("artist_view_test( )") 20 | 21 | def artist_search_test(): 22 | global failed 23 | global passed 24 | api = API("nbsmobile", "", ".xml") 25 | resp = xml.dom.minidom.parseString(api.artistSearch("Kanye")) 26 | music_id = resp.getElementsByTagName("music_brainz_id")[0].childNodes[0].data 27 | if(music_id == "164f0d73-1234-4e2c-8743-d77bf2191051"): 28 | passed += 1 29 | else: 30 | failed.append("artist_search_test( )") 31 | 32 | def artist_ranking_test(): 33 | global failed 34 | global passed 35 | api = API("nbsmobile", "", ".xml") 36 | ids = [356, 659, 8309] 37 | type = "nominal" 38 | resp = xml.dom.minidom.parseString(api.artistRanking(type, ids)) 39 | elements = resp.getElementsByTagName("name") 40 | names = [] 41 | for i in elements: 42 | names.append(i.childNodes[0].data) 43 | if(names[0] == "Lady Gaga" and names[1] == "Kanye West" and names[2] == "Chiddy Bang"): 44 | passed += 1 45 | else: 46 | failed.append("artist_ranking_test( )") 47 | 48 | def artist_add_test(): 49 | global failed 50 | global passed 51 | api = API("nbsmobile", "ad644d582c7dcf7dc29479ff2d4df1ef", ".xml") 52 | profiles = ["http://www.myspace.com/longmiles"] 53 | name = "Long Miles" 54 | resp = xml.dom.minidom.parseString(api.artistAdd(name , profiles)) 55 | message = resp.getElementsByTagName("message")[0].childNodes[0].data 56 | if(message == "That Artist already exists in our system [#324157]"): 57 | passed += 1 58 | else: 59 | failed.append("artist_ranking_test( )") 60 | 61 | def genres_artist_test(): 62 | global failed 63 | global passed 64 | api = API("nbsmobile","", ".xml") 65 | resp = xml.dom.minidom.parseString(api.genresArtist("356")) 66 | genre = resp.getElementsByTagName("name")[1].childNodes[0].data 67 | if(genre == "HipHop"): 68 | passed += 1 69 | else: 70 | failed.append("artist_ranking_test( )") 71 | 72 | def metrics_profile_test(): 73 | global failed 74 | global passed 75 | api = API("nbsmobile", "", ".xml") 76 | resp = xml.dom.minidom.parseString(api.metricsProfile("388")) 77 | metrics = len(resp.getElementsByTagName("metric")) 78 | if(metrics==4): 79 | passed += 1 80 | else: 81 | failed.append("metrics_profile_test( )") 82 | 83 | def metrics_artist_test(): 84 | global failed 85 | global passed 86 | api = API("nbsmobile","", ".xml") 87 | resp = xml.dom.minidom.parseString(api.metricsArtist("388")) 88 | service = resp.getElementsByTagName("service")[0].childNodes[0].data 89 | if(service == "MySpace"): 90 | passed += 1 91 | else: 92 | failed.append("metrics_artist_test( )") 93 | 94 | def profiles_artist_test(): 95 | global failed 96 | global passed 97 | api = API("nbsmobile", "", ".xml") 98 | resp = xml.dom.minidom.parseString(api.profilesArtist("356")) 99 | service = resp.getElementsByTagName("service")[9].childNodes[0].data 100 | if(service == "MySpace"): 101 | passed += 1 102 | else: 103 | failed.append("profiles_artist_test()") 104 | 105 | def profiles_search_test(): 106 | global failed 107 | global passed 108 | api = API("nbsmobile","", ".xml") 109 | resp = xml.dom.minidom.parseString(api.profilesSearch("http://www.myspace.com/kanyewest")) 110 | music_id = resp.getElementsByTagName("music_brainz_id")[0].childNodes[0].data 111 | if(music_id == "164f0d73-1234-4e2c-8743-d77bf2191051"): 112 | passed += 1 113 | else: 114 | failed.append("profile_search_test( )") 115 | 116 | def profiles_add_test(): 117 | global failed 118 | global passed 119 | api = API("nbsmobile", "ad644d582c7dcf7dc29479ff2d4df1ef", ".xml") 120 | profiles = ["http://www.myspace.com/longmiles"] 121 | resp = xml.dom.minidom.parseString(api.profilesAdd("324157", profiles)) 122 | name = resp.getElementsByTagName("name")[0].childNodes[0].data 123 | if(name == "Long Miles"): 124 | passed += 1 125 | else: 126 | failed.append("profiles_add_test( )") 127 | 128 | def services_list_test(): 129 | global failed 130 | global passed 131 | api = API("nbsmobile", "", ".xml") 132 | resp = xml.dom.minidom.parseString(api.servicesList()) 133 | elements = resp.getElementsByTagName("name") 134 | names = [] 135 | for i in elements: 136 | names.append(i.childNodes[0].data) 137 | if(names[0] == "MYSPACE" and names[12] == "PANDORA"): 138 | passed += 1 139 | else: 140 | failed.append("services_list_test( )") 141 | 142 | def run( ): 143 | print ">> Running XML Tests..." 144 | artist_view_test() 145 | artist_search_test() 146 | artist_ranking_test() 147 | artist_add_test() 148 | genres_artist_test() 149 | metrics_profile_test() 150 | metrics_artist_test() 151 | profiles_artist_test() 152 | profiles_search_test() 153 | profiles_add_test() 154 | services_list_test() 155 | print ">> XML Tests finished" 156 | --------------------------------------------------------------------------------