def testGetEvent(self):
        event_id = "a4a0927c-8ad7-48dd-883c-7126cc0b9c6b"
        musicbrainzngs.get_event_by_id(event_id)
        self.assertEqual("http://musicbrainz.org/ws/2/event/a4a0927c-8ad7-48dd-883c-7126cc0b9c6b", self.opener.get_url())

        # one include
        musicbrainzngs.get_event_by_id(event_id, ["artist-rels"])
        self.assertEqual("http://musicbrainz.org/ws/2/event/a4a0927c-8ad7-48dd-883c-7126cc0b9c6b?inc=artist-rels", self.opener.get_url())
Ejemplo n.º 2
0
def get_event_type(id):
    l = musicbrainzngs.get_event_by_id(id)
    try:
        t = l['event']['type'].lower()
    except KeyError:
        t = 'event'
    return t
Ejemplo n.º 3
0
    def testGetEvent(self):
        event_id = "a4a0927c-8ad7-48dd-883c-7126cc0b9c6b"
        musicbrainzngs.get_event_by_id(event_id)
        self.assertEqual("http://musicbrainz.org/ws/2/event/a4a0927c-8ad7-48dd-883c-7126cc0b9c6b", self.opener.get_url())

        # one include
        musicbrainzngs.get_event_by_id(event_id, ["artist-rels"])
        self.assertEqual("http://musicbrainz.org/ws/2/event/a4a0927c-8ad7-48dd-883c-7126cc0b9c6b?inc=artist-rels", self.opener.get_url())

        musicbrainzngs.get_event_by_id(event_id, ["artist-rels", "event-rels", "ratings", "tags"])
        self.assertEqual("http://musicbrainz.org/ws/2/event/a4a0927c-8ad7-48dd-883c-7126cc0b9c6b?inc=artist-rels+event-rels+ratings+tags", self.opener.get_url())
Ejemplo n.º 4
0
def get_event_by_id(id):
    """Get event with the MusicBrainz ID.

    Returns:
        Event object with the following includes: artist-rels, place-rels, series-rels, url-rels.
    """
    key = cache.gen_key(id)
    event = cache.get(key)
    if not event:
        try:
            event = musicbrainzngs.get_event_by_id(
                id, ['artist-rels', 'place-rels', 'series-rels', 'release-group-rels', 'url-rels']).get('event')
        except ResponseError as e:
            if e.cause.code == 404:
                return None
            else:
                raise InternalServerError(e.cause.msg)
        cache.set(key=key, val=event, time=DEFAULT_CACHE_EXPIRATION)
    return event
Ejemplo n.º 5
0
def get_event_name(id):
    l = musicbrainzngs.get_event_by_id(id)
    return l['event']['name']