Remove dead Last.fm event/venu methods
This commit is contained in:
parent
61216f73c0
commit
230439f52f
|
@ -67,10 +67,6 @@ STATUS_INVALID_SIGNATURE = 13
|
|||
STATUS_TOKEN_UNAUTHORIZED = 14
|
||||
STATUS_TOKEN_EXPIRED = 15
|
||||
|
||||
EVENT_ATTENDING = '0'
|
||||
EVENT_MAYBE_ATTENDING = '1'
|
||||
EVENT_NOT_ATTENDING = '2'
|
||||
|
||||
PERIOD_OVERALL = 'overall'
|
||||
PERIOD_7DAYS = '7day'
|
||||
PERIOD_1MONTH = '1month'
|
||||
|
@ -336,50 +332,6 @@ class _Network(object):
|
|||
|
||||
return seq
|
||||
|
||||
def get_geo_events(
|
||||
self, longitude=None, latitude=None, location=None, distance=None,
|
||||
tag=None, festivalsonly=None, limit=None, cacheable=True):
|
||||
"""
|
||||
Returns all events in a specific location by country or city name.
|
||||
Parameters:
|
||||
longitude (Optional) : Specifies a longitude value to retrieve events
|
||||
for (service returns nearby events by default)
|
||||
latitude (Optional) : Specifies a latitude value to retrieve events for
|
||||
(service returns nearby events by default)
|
||||
location (Optional) : Specifies a location to retrieve events for
|
||||
(service returns nearby events by default)
|
||||
distance (Optional) : Find events within a specified radius
|
||||
(in kilometres)
|
||||
tag (Optional) : Specifies a tag to filter by.
|
||||
festivalsonly[0|1] (Optional) : Whether only festivals should be
|
||||
returned, or all events.
|
||||
limit (Optional) : The number of results to fetch per page.
|
||||
Defaults to 10.
|
||||
"""
|
||||
|
||||
params = {}
|
||||
|
||||
if longitude:
|
||||
params["long"] = longitude
|
||||
if latitude:
|
||||
params["lat"] = latitude
|
||||
if location:
|
||||
params["location"] = location
|
||||
if limit:
|
||||
params["limit"] = limit
|
||||
if distance:
|
||||
params["distance"] = distance
|
||||
if tag:
|
||||
params["tag"] = tag
|
||||
if festivalsonly:
|
||||
params["festivalsonly"] = 1
|
||||
elif not festivalsonly:
|
||||
params["festivalsonly"] = 0
|
||||
|
||||
doc = _Request(self, "geo.getEvents", params).execute(cacheable)
|
||||
|
||||
return _extract_events_from_doc(doc, self)
|
||||
|
||||
def get_metro_weekly_chart_dates(self, cacheable=True):
|
||||
"""
|
||||
Returns a list of From and To tuples for the available metro charts.
|
||||
|
@ -554,14 +506,6 @@ class _Network(object):
|
|||
|
||||
return TrackSearch(artist_name, track_name, self)
|
||||
|
||||
def search_for_venue(self, venue_name, country_name):
|
||||
"""Searches of a venue by its name and its country. Set country_name to
|
||||
an empty string if not available.
|
||||
Returns a VenueSearch object.
|
||||
Use get_next_page() to retrieve sequences of results."""
|
||||
|
||||
return VenueSearch(venue_name, country_name, self)
|
||||
|
||||
def get_track_by_mbid(self, mbid):
|
||||
"""Looks up a track by its MusicBrainz ID"""
|
||||
|
||||
|
@ -755,7 +699,6 @@ class LastFMNetwork(_Network):
|
|||
urls={
|
||||
"album": "music/%(artist)s/%(album)s",
|
||||
"artist": "music/%(artist)s",
|
||||
"event": "event/%(id)s",
|
||||
"country": "place/%(country_name)s",
|
||||
"tag": "tag/%(name)s",
|
||||
"track": "music/%(artist)s/_/%(title)s",
|
||||
|
@ -818,7 +761,6 @@ class LibreFMNetwork(_Network):
|
|||
urls={
|
||||
"album": "artist/%(artist)s/album/%(album)s",
|
||||
"artist": "artist/%(artist)s",
|
||||
"event": "event/%(id)s",
|
||||
"country": "place/%(country_name)s",
|
||||
"tag": "tag/%(name)s",
|
||||
"track": "music/%(artist)s/_/%(title)s",
|
||||
|
@ -1195,7 +1137,7 @@ class _BaseObject(object):
|
|||
* users [User|str,]: A list that can contain usernames, emails,
|
||||
User objects, or all of them.
|
||||
* message str: A message to include in the recommendation message.
|
||||
Only for Artist/Event/Track.
|
||||
Only for Artist/Track.
|
||||
"""
|
||||
|
||||
# Last.fm currently accepts a max of 10 recipient at a time
|
||||
|
@ -1895,168 +1837,6 @@ class Artist(_BaseObject, _Taggable):
|
|||
return names
|
||||
|
||||
|
||||
class Event(_BaseObject):
|
||||
"""An event."""
|
||||
|
||||
id = None
|
||||
|
||||
__hash__ = _BaseObject.__hash__
|
||||
|
||||
def __init__(self, event_id, network):
|
||||
_BaseObject.__init__(self, network, 'event')
|
||||
|
||||
self.id = event_id
|
||||
|
||||
def __repr__(self):
|
||||
return "pylast.Event(%s, %s)" % (repr(self.id), repr(self.network))
|
||||
|
||||
@_string_output
|
||||
def __str__(self):
|
||||
return "Event #" + str(self.get_id())
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) is type(other):
|
||||
return self.get_id() == other.get_id()
|
||||
else:
|
||||
return False
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def _get_params(self):
|
||||
return {'event': self.get_id()}
|
||||
|
||||
def attend(self, attending_status):
|
||||
"""Sets the attending status.
|
||||
* attending_status: The attending status. Possible values:
|
||||
o EVENT_ATTENDING
|
||||
o EVENT_MAYBE_ATTENDING
|
||||
o EVENT_NOT_ATTENDING
|
||||
"""
|
||||
|
||||
params = self._get_params()
|
||||
params['status'] = attending_status
|
||||
|
||||
self._request('event.attend', False, params)
|
||||
|
||||
def get_attendees(self):
|
||||
"""
|
||||
Get a list of attendees for an event
|
||||
"""
|
||||
|
||||
doc = self._request("event.getAttendees", False)
|
||||
|
||||
users = []
|
||||
for name in _extract_all(doc, "name"):
|
||||
users.append(User(name, self.network))
|
||||
|
||||
return users
|
||||
|
||||
def get_id(self):
|
||||
"""Returns the id of the event on the network. """
|
||||
|
||||
return self.id
|
||||
|
||||
def get_title(self):
|
||||
"""Returns the title of the event. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _extract(doc, "title")
|
||||
|
||||
def get_headliner(self):
|
||||
"""Returns the headliner of the event. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return Artist(_extract(doc, "headliner"), self.network)
|
||||
|
||||
def get_artists(self):
|
||||
"""Returns a list of the participating Artists. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
names = _extract_all(doc, "artist")
|
||||
|
||||
artists = []
|
||||
for name in names:
|
||||
artists.append(Artist(name, self.network))
|
||||
|
||||
return artists
|
||||
|
||||
def get_venue(self):
|
||||
"""Returns the venue where the event is held."""
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
v = doc.getElementsByTagName("venue")[0]
|
||||
venue_id = _number(_extract(v, "id"))
|
||||
|
||||
return Venue(venue_id, self.network, venue_element=v)
|
||||
|
||||
def get_start_date(self):
|
||||
"""Returns the date when the event starts."""
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _extract(doc, "startDate")
|
||||
|
||||
def get_description(self):
|
||||
"""Returns the description of the event. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _extract(doc, "description")
|
||||
|
||||
def get_cover_image(self, size=COVER_MEGA):
|
||||
"""
|
||||
Returns a uri to the cover image
|
||||
size can be one of:
|
||||
COVER_MEGA
|
||||
COVER_EXTRA_LARGE
|
||||
COVER_LARGE
|
||||
COVER_MEDIUM
|
||||
COVER_SMALL
|
||||
"""
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _extract_all(doc, "image")[size]
|
||||
|
||||
def get_attendance_count(self):
|
||||
"""Returns the number of attending people. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _number(_extract(doc, "attendance"))
|
||||
|
||||
def get_review_count(self):
|
||||
"""Returns the number of available reviews for this event. """
|
||||
|
||||
doc = self._request("event.getInfo", True)
|
||||
|
||||
return _number(_extract(doc, "reviews"))
|
||||
|
||||
def get_url(self, domain_name=DOMAIN_ENGLISH):
|
||||
"""Returns the url of the event page on the network.
|
||||
* domain_name: The network's language domain. Possible values:
|
||||
o DOMAIN_ENGLISH
|
||||
o DOMAIN_GERMAN
|
||||
o DOMAIN_SPANISH
|
||||
o DOMAIN_FRENCH
|
||||
o DOMAIN_ITALIAN
|
||||
o DOMAIN_POLISH
|
||||
o DOMAIN_PORTUGUESE
|
||||
o DOMAIN_SWEDISH
|
||||
o DOMAIN_TURKISH
|
||||
o DOMAIN_RUSSIAN
|
||||
o DOMAIN_JAPANESE
|
||||
o DOMAIN_CHINESE
|
||||
"""
|
||||
|
||||
return self.network._get_url(
|
||||
domain_name, "event") % {'id': self.get_id()}
|
||||
|
||||
|
||||
class Country(_BaseObject):
|
||||
"""A country at Last.fm."""
|
||||
|
||||
|
@ -2110,7 +1890,7 @@ class Country(_BaseObject):
|
|||
"getTopTracks", "track", Track, params, cacheable)
|
||||
|
||||
def get_url(self, domain_name=DOMAIN_ENGLISH):
|
||||
"""Returns the url of the event page on the network.
|
||||
"""Returns the url of the country page on the network.
|
||||
* domain_name: The network's language domain. Possible values:
|
||||
o DOMAIN_ENGLISH
|
||||
o DOMAIN_GERMAN
|
||||
|
@ -2615,13 +2395,6 @@ class User(_BaseObject, _Chartable):
|
|||
|
||||
return self.name
|
||||
|
||||
def get_upcoming_events(self):
|
||||
"""Returns all the upcoming events for this user."""
|
||||
|
||||
doc = self._request(self.ws_prefix + '.getEvents', True)
|
||||
|
||||
return _extract_events_from_doc(doc, self.network)
|
||||
|
||||
def get_artist_tracks(self, artist, cacheable=False):
|
||||
"""
|
||||
Get a list of tracks by a given artist scrobbled by this user,
|
||||
|
@ -2716,22 +2489,6 @@ class User(_BaseObject, _Chartable):
|
|||
|
||||
return seq
|
||||
|
||||
def get_past_events(self, limit=50, cacheable=False):
|
||||
"""
|
||||
Returns a sequence of Event objects
|
||||
if limit==None it will return all
|
||||
"""
|
||||
|
||||
seq = []
|
||||
for node in _collect_nodes(
|
||||
limit,
|
||||
self,
|
||||
self.ws_prefix + ".getPastEvents",
|
||||
cacheable):
|
||||
seq.append(Event(_extract(node, "id"), self.network))
|
||||
|
||||
return seq
|
||||
|
||||
def get_now_playing(self):
|
||||
"""
|
||||
Returns the currently playing track, or None if nothing is playing.
|
||||
|
@ -3086,19 +2843,6 @@ class AuthenticatedUser(User):
|
|||
self.name = _extract(doc, "name")
|
||||
return self.name
|
||||
|
||||
def get_recommended_events(self, limit=50, cacheable=False):
|
||||
"""
|
||||
Returns a sequence of Event objects
|
||||
if limit==None it will return all
|
||||
"""
|
||||
|
||||
seq = []
|
||||
for node in _collect_nodes(
|
||||
limit, self, "user.getRecommendedEvents", cacheable):
|
||||
seq.append(Event(_extract(node, "id"), self.network))
|
||||
|
||||
return seq
|
||||
|
||||
def get_recommended_artists(self, limit=50, cacheable=False):
|
||||
"""
|
||||
Returns a sequence of Artist objects
|
||||
|
@ -3247,106 +2991,6 @@ class TrackSearch(_Search):
|
|||
return seq
|
||||
|
||||
|
||||
class VenueSearch(_Search):
|
||||
"""
|
||||
Search for a venue by its name. If you don't want to narrow the results
|
||||
down by specifying a country, set it to empty string.
|
||||
"""
|
||||
|
||||
def __init__(self, venue_name, country_name, network):
|
||||
|
||||
_Search.__init__(
|
||||
self,
|
||||
"venue",
|
||||
{"venue": venue_name, "country": country_name},
|
||||
network)
|
||||
|
||||
def get_next_page(self):
|
||||
"""Returns the next page of results as a sequence of Track objects."""
|
||||
|
||||
master_node = self._retrieve_next_page()
|
||||
|
||||
seq = []
|
||||
for node in master_node.getElementsByTagName("venue"):
|
||||
seq.append(Venue(_extract(node, "id"), self.network))
|
||||
|
||||
return seq
|
||||
|
||||
|
||||
class Venue(_BaseObject):
|
||||
"""A venue where events are held."""
|
||||
|
||||
# TODO: waiting for a venue.getInfo web service to use.
|
||||
# TODO: As an intermediate use case, can pass the venue DOM element when
|
||||
# using Event.get_venue() to populate the venue info, if the venue.getInfo
|
||||
# API call becomes available this workaround should be removed
|
||||
|
||||
id = None
|
||||
info = None
|
||||
name = None
|
||||
location = None
|
||||
url = None
|
||||
|
||||
__hash__ = _BaseObject.__hash__
|
||||
|
||||
def __init__(self, netword_id, network, venue_element=None):
|
||||
_BaseObject.__init__(self, network, "venue")
|
||||
|
||||
self.id = _number(netword_id)
|
||||
if venue_element is not None:
|
||||
self.info = _extract_element_tree(venue_element)
|
||||
self.name = self.info.get('name')
|
||||
self.url = self.info.get('url')
|
||||
self.location = self.info.get('location')
|
||||
|
||||
def __repr__(self):
|
||||
return "pylast.Venue(%s, %s)" % (repr(self.id), repr(self.network))
|
||||
|
||||
@_string_output
|
||||
def __str__(self):
|
||||
return "Venue #" + str(self.id)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.get_id() == other.get_id()
|
||||
|
||||
def _get_params(self):
|
||||
return {self.ws_prefix: self.get_id()}
|
||||
|
||||
def get_id(self):
|
||||
"""Returns the id of the venue."""
|
||||
|
||||
return self.id
|
||||
|
||||
def get_name(self):
|
||||
"""Returns the name of the venue."""
|
||||
|
||||
return self.name
|
||||
|
||||
def get_url(self):
|
||||
"""Returns the URL of the venue page."""
|
||||
|
||||
return self.url
|
||||
|
||||
def get_location(self):
|
||||
"""Returns the location of the venue (dictionary)."""
|
||||
|
||||
return self.location
|
||||
|
||||
def get_upcoming_events(self):
|
||||
"""Returns the upcoming events in this venue."""
|
||||
|
||||
doc = self._request(self.ws_prefix + ".getEvents", True)
|
||||
|
||||
return _extract_events_from_doc(doc, self.network)
|
||||
|
||||
def get_past_events(self):
|
||||
"""Returns the past events held in this venue."""
|
||||
|
||||
doc = self._request(self.ws_prefix + ".getEvents", True)
|
||||
|
||||
return _extract_events_from_doc(doc, self.network)
|
||||
|
||||
|
||||
def md5(text):
|
||||
"""Returns the md5 hash of a string."""
|
||||
|
||||
|
@ -3534,13 +3178,6 @@ def _extract_tracks(doc, network):
|
|||
return seq
|
||||
|
||||
|
||||
def _extract_events_from_doc(doc, network):
|
||||
events = []
|
||||
for node in doc.getElementsByTagName("event"):
|
||||
events.append(Event(_extract(node, "id"), network))
|
||||
return events
|
||||
|
||||
|
||||
def _url_safe(text):
|
||||
"""Does all kinds of tricks on a text to make it safe to use in a url."""
|
||||
|
||||
|
|
|
@ -73,18 +73,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertEqual(str(last_scrobble.track.title), str(title))
|
||||
self.assertEqual(str(last_scrobble.timestamp), str(timestamp))
|
||||
|
||||
def test_get_venue(self):
|
||||
# Arrange
|
||||
venue_name = "Last.fm Office"
|
||||
country_name = "United Kingdom"
|
||||
|
||||
# Act
|
||||
venue_search = self.network.search_for_venue(venue_name, country_name)
|
||||
venue = venue_search.get_next_page()[0]
|
||||
|
||||
# Assert
|
||||
self.assertEqual(str(venue.id), "8778225")
|
||||
|
||||
def test_get_user_registration(self):
|
||||
# Arrange
|
||||
username = "RJ"
|
||||
|
@ -279,14 +267,6 @@ class TestPyLast(unittest.TestCase):
|
|||
# Act/Assert
|
||||
self.helper_is_thing_hashable(metro)
|
||||
|
||||
def test_event_is_hashable(self):
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
event = user.get_past_events(limit=1)[0]
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(event)
|
||||
|
||||
def test_library_is_hashable(self):
|
||||
# Arrange
|
||||
library = pylast.Library(user=self.username, network=self.network)
|
||||
|
@ -317,14 +297,6 @@ class TestPyLast(unittest.TestCase):
|
|||
# Act/Assert
|
||||
self.helper_is_thing_hashable(user)
|
||||
|
||||
def test_venue_is_hashable(self):
|
||||
# Arrange
|
||||
venue_id = "8778225" # Last.fm office
|
||||
venue = pylast.Venue(venue_id, self.network)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(venue)
|
||||
|
||||
def test_invalid_xml(self):
|
||||
# Arrange
|
||||
# Currently causes PCDATA invalid Char value 25
|
||||
|
@ -436,67 +408,6 @@ class TestPyLast(unittest.TestCase):
|
|||
# # Assert
|
||||
# self.assertGreaterEqual(len(tracks), 0)
|
||||
|
||||
def helper_past_events_have_valid_ids(self, thing):
|
||||
# Act
|
||||
events = thing.get_past_events()
|
||||
|
||||
# Assert
|
||||
self.helper_assert_events_have_valid_ids(events)
|
||||
|
||||
def helper_upcoming_events_have_valid_ids(self, thing):
|
||||
# Act
|
||||
events = thing.get_upcoming_events()
|
||||
|
||||
# Assert
|
||||
self.helper_assert_events_have_valid_ids(events)
|
||||
|
||||
def helper_assert_events_have_valid_ids(self, events):
|
||||
# Assert
|
||||
# If fails, add past/future event for user/Test Artist:
|
||||
self.assertGreaterEqual(len(events), 1)
|
||||
for event in events[:2]: # checking first two should be enough
|
||||
self.assertIsInstance(event.get_headliner(), pylast.Artist)
|
||||
|
||||
def test_user_past_events_returns_valid_ids(self):
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_past_events_have_valid_ids(lastfm_user)
|
||||
|
||||
def test_user_recommended_events_returns_valid_ids(self):
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
# Act
|
||||
events = lastfm_user.get_upcoming_events()
|
||||
|
||||
# Assert
|
||||
self.helper_assert_events_have_valid_ids(events)
|
||||
|
||||
def test_user_upcoming_events_returns_valid_ids(self):
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_upcoming_events_have_valid_ids(lastfm_user)
|
||||
|
||||
def test_venue_past_events_returns_valid_ids(self):
|
||||
# Arrange
|
||||
venue_id = "8778225" # Last.fm office
|
||||
venue = pylast.Venue(venue_id, self.network)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_past_events_have_valid_ids(venue)
|
||||
|
||||
def test_venue_upcoming_events_returns_valid_ids(self):
|
||||
# Arrange
|
||||
venue_id = "8778225" # Last.fm office
|
||||
venue = pylast.Venue(venue_id, self.network)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_upcoming_events_have_valid_ids(venue)
|
||||
|
||||
def test_pickle(self):
|
||||
# Arrange
|
||||
import pickle
|
||||
|
@ -660,43 +571,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.helper_validate_cacheable(lastfm_user, "get_loved_tracks")
|
||||
self.helper_validate_cacheable(lastfm_user, "get_recent_tracks")
|
||||
|
||||
def test_geo_get_events_in_location(self):
|
||||
# Arrange
|
||||
# Act
|
||||
events = self.network.get_geo_events(
|
||||
location="London", tag="blues", limit=1)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(len(events), 1)
|
||||
event = events[0]
|
||||
self.assertIsInstance(event, pylast.Event)
|
||||
self.assertIn(event.get_venue().location['city'],
|
||||
["London", "Camden"])
|
||||
|
||||
def test_geo_get_events_in_latlong(self):
|
||||
# Arrange
|
||||
# Act
|
||||
events = self.network.get_geo_events(
|
||||
latitude=53.466667, longitude=-2.233333, distance=5, limit=1)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(len(events), 1)
|
||||
event = events[0]
|
||||
self.assertIsInstance(event, pylast.Event)
|
||||
self.assertEqual(event.get_venue().location['city'], "Manchester")
|
||||
|
||||
def test_geo_get_events_festival(self):
|
||||
# Arrange
|
||||
# Act
|
||||
events = self.network.get_geo_events(
|
||||
location="Reading", festivalsonly=True, limit=1)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(len(events), 1)
|
||||
event = events[0]
|
||||
self.assertIsInstance(event, pylast.Event)
|
||||
self.assertEqual(event.get_venue().location['city'], "Reading")
|
||||
|
||||
def helper_dates_valid(self, dates):
|
||||
# Assert
|
||||
self.assertGreaterEqual(len(dates), 1)
|
||||
|
@ -992,17 +866,15 @@ class TestPyLast(unittest.TestCase):
|
|||
# spam_message = "Dig the krazee sound!"
|
||||
# artist = self.network.get_top_artists(limit=1)[0].item
|
||||
# track = artist.get_top_tracks(limit=1)[0].item
|
||||
# event = artist.get_upcoming_events()[0]
|
||||
|
||||
# # Act
|
||||
# artist.share(users_to_spam, spam_message)
|
||||
# track.share(users_to_spam, spam_message)
|
||||
# event.share(users_to_spam, spam_message)
|
||||
|
||||
# Assert
|
||||
# Check inbox for spam!
|
||||
|
||||
# album/artist/event/track/user
|
||||
# album/artist/track/user
|
||||
|
||||
def test_album_data(self):
|
||||
# Arrange
|
||||
|
@ -1217,18 +1089,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertIsInstance(count, int)
|
||||
self.assertGreater(count, 0)
|
||||
|
||||
def test_event_attendees(self):
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
event = user.get_past_events(limit=1)[0]
|
||||
|
||||
# Act
|
||||
users = event.get_attendees()
|
||||
|
||||
# Assert
|
||||
self.assertIsInstance(users, list)
|
||||
self.assertIsInstance(users[0], pylast.User)
|
||||
|
||||
def test_tag_artist(self):
|
||||
# Arrange
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
|
@ -1443,40 +1303,6 @@ class TestPyLast(unittest.TestCase):
|
|||
self.assertEqual(mbid, "a74b1b7f-71a5-4011-9441-d0b5e4122711")
|
||||
self.assertIsInstance(streamable, bool)
|
||||
|
||||
def test_events(self):
|
||||
# Arrange
|
||||
event_id_1 = 3162700 # Glasto 2013
|
||||
event_id_2 = 3478520 # Glasto 2014
|
||||
event1 = pylast.Event(event_id_1, self.network)
|
||||
event2 = pylast.Event(event_id_2, self.network)
|
||||
|
||||
# Act
|
||||
text = str(event1)
|
||||
rep = repr(event1)
|
||||
title = event1.get_title()
|
||||
artists = event1.get_artists()
|
||||
start = event1.get_start_date()
|
||||
description = event1.get_description()
|
||||
review_count = event1.get_review_count()
|
||||
attendance_count = event1.get_attendance_count()
|
||||
|
||||
# Assert
|
||||
self.assertIn("3162700", rep)
|
||||
self.assertIn("pylast.Event", rep)
|
||||
self.assertEqual(text, "Event #3162700")
|
||||
self.assertTrue(event1 != event2)
|
||||
self.assertIn("Glastonbury", title)
|
||||
found = False
|
||||
for artist in artists:
|
||||
if artist.name == "The Rolling Stones":
|
||||
found = True
|
||||
break
|
||||
self.assertTrue(found)
|
||||
self.assertIn("Wed, 26 Jun 2013", start)
|
||||
self.assertIn("astonishing bundle", description)
|
||||
self.assertGreater(review_count, 0)
|
||||
self.assertGreater(attendance_count, 100)
|
||||
|
||||
def test_countries(self):
|
||||
# Arrange
|
||||
country1 = pylast.Country("Italy", self.network)
|
||||
|
@ -1543,24 +1369,6 @@ class TestPyLast(unittest.TestCase):
|
|||
# Act / Assert
|
||||
self.assertTrue(album1 != album2)
|
||||
|
||||
def test_event_eq_none_is_false(self):
|
||||
# Arrange
|
||||
event1 = None
|
||||
event_id = 3478520 # Glasto 2014
|
||||
event2 = pylast.Event(event_id, self.network)
|
||||
|
||||
# Act / Assert
|
||||
self.assertFalse(event1 == event2)
|
||||
|
||||
def test_event_ne_none_is_true(self):
|
||||
# Arrange
|
||||
event1 = None
|
||||
event_id = 3478520 # Glasto 2014
|
||||
event2 = pylast.Event(event_id, self.network)
|
||||
|
||||
# Act / Assert
|
||||
self.assertTrue(event1 != event2)
|
||||
|
||||
def test_band_members(self):
|
||||
# Arrange
|
||||
artist = pylast.Artist("The Beatles", self.network)
|
||||
|
|
Loading…
Reference in a new issue