def test_remove_track(HttpMock): client = init_client() test_member_id = get_random_md5() username = '******' firstname = 'Test' lastname = 'User' email = '*****@*****.**' xml_str = """<memberaccount id="%(test_member_id)s"> <username>%(username)s</username> <firstname>%(firstname)s</firstname> <lastname>%(lastname)s</lastname> <email>%(email)s</email> </memberaccount>""" % \ {'test_member_id': test_member_id, 'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email} member_xml = ET.fromstring(xml_str) member = Member._from_xml(member_xml, client) xml_response = """<?xml version="1.0" encoding="utf-8"?> <responsecode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <code>OK</code> </responsecode>""" http = build_http_mock(HttpMock, content=xml_response) test_track_id = get_random_md5() member.remove_favourite(test_track_id)
def test_from_xml(): client = init_client() test_member_id = get_random_md5() username = '******' firstname = 'Test' lastname = 'User' email = '*****@*****.**' xml_str = """<memberaccount id="%(test_member_id)s"> <username>%(username)s</username> <firstname>%(firstname)s</firstname> <lastname>%(lastname)s</lastname> <email>%(email)s</email> </memberaccount>""" % \ {'test_member_id': test_member_id, 'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email} member_xml = ET.fromstring(xml_str) member = Member._from_xml(member_xml, client) assert member.id == test_member_id assert member.firstname == firstname
def test_get_member_playlists(HttpMock): client = init_client() test_member_id = get_random_md5() username = '******' firstname = 'Test' lastname = 'User' email = '*****@*****.**' member_xml = ET.fromstring("""<memberaccount id="%(test_member_id)s"> <username>%(username)s</username> <firstname>%(firstname)s</firstname> <lastname>%(lastname)s</lastname> <email>%(email)s</email> </memberaccount>""" % {'test_member_id': test_member_id, 'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email}) member = Member._from_xml(member_xml, client) test_playlist_id = get_random_md5() test_playlist_name = 'test playlist' content = """<?xml version="1.0" encoding="utf-8"?> <ResponsePlaylists> <playlists> <playlist id="%(id)s" name="%(name)s"> <tracks> <track tracknumber="001" time="02:50" lengthseconds="170" comment="Make sure you’re down the front for this fiery Post Punk workout." composer=""S. Milton, J. Wygens"" publisher="HM" name="Guerilla Pop" id="17376d36f309f18d" keywords="" lyrics="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation="" bpm="" mixout="" frequency="44100" bitrate="1411" /> </tracks> </playlist> </playlists> </ResponsePlaylists>""" % {'id': test_playlist_id, 'name': test_playlist_name} http = build_http_mock(HttpMock, content=content) playlists = member.get_playlists() assert isinstance(playlists, list) playlist = playlists[0] assert playlist.id == test_playlist_id assert playlist.name == test_playlist_name
def test_get_member_favourites(HttpMock): client = init_client() test_member_id = get_random_md5() username = '******' firstname = 'Test' lastname = 'User' email = '*****@*****.**' member_xml = ET.fromstring("""<memberaccount id="%(test_member_id)s"> <username>%(username)s</username> <firstname>%(firstname)s</firstname> <lastname>%(lastname)s</lastname> <email>%(email)s</email> </memberaccount>""" % \ {'test_member_id': test_member_id, 'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email}) member = Member._from_xml(member_xml, client) test_track_id = get_random_md5() test_track_name = 'test track' xml_response = """<?xml version="1.0" encoding="utf-8"?> <ResponseFavourites> <favourites> <tracks> <track id="%(id)s" name="%(name)s" /> </tracks> </favourites> </ResponseFavourites>""" % { 'id': test_track_id, 'name': test_track_name } http = build_http_mock(HttpMock, content=xml_response) favourites = member.get_favourites() assert isinstance(favourites, list) favourite = favourites[0] assert favourite.id == test_track_id assert favourite.name == test_track_name
def test_get_member_favourites(HttpMock): client = init_client() test_member_id = get_random_md5() username = '******' firstname = 'Test' lastname = 'User' email = '*****@*****.**' member_xml = ET.fromstring("""<memberaccount id="%(test_member_id)s"> <username>%(username)s</username> <firstname>%(firstname)s</firstname> <lastname>%(lastname)s</lastname> <email>%(email)s</email> </memberaccount>""" % \ {'test_member_id': test_member_id, 'username': username, 'firstname': firstname, 'lastname': lastname, 'email': email}) member = Member._from_xml(member_xml, client) test_track_id = get_random_md5() test_track_name = 'test track' xml_response = """<?xml version="1.0" encoding="utf-8"?> <ResponseFavourites> <favourites> <tracks> <track id="%(id)s" name="%(name)s" /> </tracks> </favourites> </ResponseFavourites>""" % {'id': test_track_id, 'name': test_track_name} http = build_http_mock(HttpMock, content=xml_response) favourites = member.get_favourites() assert isinstance(favourites, list) favourite = favourites[0] assert favourite.id == test_track_id assert favourite.name == test_track_name