예제 #1
0
    def test_get_recent_setlists(self):
        api = PhishNetAPI()
        recent_setlists_response = api.get_recent_setlists()

        assert recent_setlists_response['error_code'] == 0
        assert recent_setlists_response['response']['count'] == 10
        assert len(recent_setlists_response['response']['data']) == 10
예제 #2
0
    def test_get_random_setlist(self):
        api = PhishNetAPI()
        random_setlist_response = api.get_random_setlist()

        assert random_setlist_response['error_code'] == 0
        assert random_setlist_response['response']['count'] == 1
        assert len(random_setlist_response['response']['data']) == 1
예제 #3
0
    def test_get_show_links(self):
        api = PhishNetAPI()
        show_links_response = api.get_show_links(1394573037)

        assert show_links_response['error_code'] == 0
        assert show_links_response['response']['count'] == len(
            show_links_response['response']['data'])
예제 #4
0
    def test_get_upcoming_shows(self):
        api = PhishNetAPI()
        upcoming_shows_response = api.get_upcoming_shows()

        assert upcoming_shows_response['error_code'] == 0
        assert upcoming_shows_response['response']['count'] == len(
            upcoming_shows_response['response']['data'])
예제 #5
0
    def test_get_setlist(self):
        api = PhishNetAPI()
        setlist_response = api.get_setlist(showid=1252698446)

        assert setlist_response['error_code'] == 0
        assert setlist_response['response']['count'] == 1
        assert len(setlist_response['response']['data']) == 1
        assert setlist_response['response']['data'][0]['showid'] == 1252698446
        assert setlist_response['response']['data'][0][
            'showdate'] == '1997-12-29'
        assert setlist_response['response']['data'][0]['rating'] == '4.5907'
        assert setlist_response['response']['data'][0][
            'location'] == 'New York, NY, USA'

        get_setlists_response = api.get_setlist(showdate='1997-12-29')

        assert setlist_response['error_code'] == 0
        assert get_setlists_response['response']['count'] == 1
        assert len(get_setlists_response['response']['data']) == 1
        assert get_setlists_response['response']['data'][0][
            'showid'] == 1252698446
        assert setlist_response['response']['data'][0][
            'showdate'] == '1997-12-29'
        assert setlist_response['response']['data'][0]['rating'] == '4.5907'
        assert setlist_response['response']['data'][0][
            'location'] == 'New York, NY, USA'
예제 #6
0
    def test_get_latest_setlist(self):
        api = PhishNetAPI()
        latest_setlist_response = api.get_latest_setlist()

        assert latest_setlist_response['error_code'] == 0
        assert latest_setlist_response['response']['count'] == len(
            latest_setlist_response['response']['data'])
예제 #7
0
    def test_get_venue(self):
        api = PhishNetAPI()
        venue_response = api.get_venue(1)

        assert venue_response['error_code'] == 0
        assert venue_response['response']['count'] == 9
        assert venue_response['response']['data']['venueid'] == 1
예제 #8
0
    def test_get_all_people(self):
        api = PhishNetAPI()
        people_response = api.get_all_people()

        assert people_response['error_code'] == 0
        assert people_response['response']['count'] == len(
            people_response['response']['data'])
예제 #9
0
    def test_get_all_jamcharts(self):
        api = PhishNetAPI()
        jamcharts_response = api.get_all_jamcharts()

        assert jamcharts_response['error_code'] == 0
        assert jamcharts_response['response']['count'] == len(
            jamcharts_response['response']['data'])
예제 #10
0
    def test_query_reviews(self):
        api = PhishNetAPI()
        reviews_response = api.query_reviews(showid=1394573037)

        assert reviews_response['error_code'] == 0
        assert reviews_response['response']['count'] == len(
            reviews_response['response']['data'])
예제 #11
0
    def test_query_collections(self):
        api = PhishNetAPI()
        collections_response = api.query_collections(uid=1)

        assert collections_response['error_code'] == 0
        assert collections_response['response']['count'] == len(
            collections_response['response']['data'])
예제 #12
0
    def test_get_collection(self):
        api = PhishNetAPI()
        collection_response = api.get_collection(1294148902)

        assert collection_response['error_code'] == 0
        assert collection_response['response']['data']['show_count'] == len(
            collection_response['response']['data']['shows'])
예제 #13
0
    def test_update_show_attendance(self):
        api = PhishNetAPI()
        api.uid = os.getenv('UID')
        update_attendance_response = api.update_show_attendance(
            api.uid, showid=1252691618, update='add')

        assert update_attendance_response['error_code'] == 0
        assert update_attendance_response[
            'error_message'] == "Successfully added 1997-11-30"
        assert update_attendance_response['response']['data'][
            'action'] == 'add'
        assert update_attendance_response['response']['data'][
            'showdate'] == '1997-11-30'
        assert update_attendance_response['response']['data'][
            'showid'] == 1252691618
        shows_seen_after_add = int(
            update_attendance_response['response']['data']['shows_seen'])

        update_attendance_response = api.update_show_attendance(
            api.uid, showid=1252691618, update='remove')

        assert update_attendance_response['error_code'] == 0
        assert update_attendance_response[
            'error_message'] == "Successfully removed 1997-11-30"
        shows_seen_after_remove = int(
            update_attendance_response['response']['data']['shows_seen'])
        assert shows_seen_after_add > shows_seen_after_remove
        assert update_attendance_response['response']['data'][
            'action'] == 'remove'
        assert update_attendance_response['response']['data'][
            'showdate'] == '1997-11-30'
        assert update_attendance_response['response']['data'][
            'showid'] == 1252691618
예제 #14
0
    def test_get_relationships(self):
        api = PhishNetAPI()
        relationships_response = api.get_relationships(1)

        assert relationships_response['error_code'] == 0
        assert relationships_response['response']['count'] == len(
            relationships_response['response']['data'].keys())
예제 #15
0
    def test_get_recent_blogs(self):
        api = PhishNetAPI()
        blogs_response = api.get_recent_blogs()

        assert blogs_response['error_code'] == 0
        assert blogs_response['response']['count'] == len(
            blogs_response['response']['data'])
예제 #16
0
    def test_get_all_people_types(self):
        api = PhishNetAPI()
        people_types_response = api.get_all_people_types()

        assert people_types_response['error_code'] == 0
        assert people_types_response['response']['count'] == len(
            people_types_response['response']['data'].keys())
        assert people_types_response['response']['data']["1"] == "The Band"
예제 #17
0
    def test_get_artists(self):
        api = PhishNetAPI()
        artists_response = api.get_artists()

        assert artists_response['error_code'] == 0
        assert artists_response['response']['count'] == len(
            artists_response['response']['data'])
        assert artists_response['response']['data']['1']['artistid'] == 1
예제 #18
0
 def test_get_recent_blogs(self, requests_mock):
     api = PhishNetAPI('apikey123456789test1')
     with open('tests/data/recent_blogs.json') as f:
         recent_blogs_json = json.load(f)
     requests_mock.post(api.base_url + "blog/get", json=recent_blogs_json)
     blogs_response = api.get_recent_blogs()
     assert blogs_response['response']['count'] == 3
     assert len(blogs_response['response']['data']) == 3
예제 #19
0
    def test_get_jamchart(self):
        api = PhishNetAPI()
        jamchart_response = api.get_jamchart(7)

        assert jamchart_response['error_code'] == 0
        assert jamchart_response['response']['data']['songid'] == 7
        assert jamchart_response['response']['count'] == len(
            jamchart_response['response']['data'])
예제 #20
0
    def test_get_all_venues(self):
        api = PhishNetAPI()
        venues_response = api.get_all_venues()

        assert venues_response['error_code'] == 0
        assert venues_response['response']['count'] == len(
            venues_response['response']['data'])
        assert venues_response['response']['data']['1']['venueid'] == 1
예제 #21
0
    def test_get_venue(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/get_venue.json') as f:
            get_venue_json = json.load(f)
        requests_mock.post(api.base_url + "venues/get", json=get_venue_json)

        venue_response = api.get_venue(1)
        assert venue_response['response']['count'] == 9
        assert venue_response['response']['data']['venueid'] == 1
예제 #22
0
 def test_authorize(self, requests_mock):
     api = PhishNetAPI('apikey123456789test1')
     with open('tests/data/authority.json') as f:
         authority_json = json.load(f)
     requests_mock.post(api.base_url + "authority/get", json=authority_json)
     api.authorize(80, '123456789abcdefghij')
     assert api.uid == 80
     assert api.appid == 12345
     assert api.authkey == "B6386A2485D94C73DAA"
예제 #23
0
    def test_authorize(self):
        api = PhishNetAPI()
        api.authorize(os.getenv("UID"))

        assert api.uid == os.getenv("UID")
        assert api.apikey == os.getenv("APIKEY")
        assert api.appid == int(os.getenv("APPID"))
        assert api.private_salt == os.getenv("PRIVATE_SALT")
        assert 18 <= len(api.authkey) <= 19
예제 #24
0
    def test_get_collection(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/get_collection.json') as f:
            get_collection_json = json.load(f)
        requests_mock.post(api.base_url + "collections/get",
                           json=get_collection_json)

        collection_response = api.get_collection(1294148902)
        assert collection_response['response']['data']['show_count'] == 7
        assert len(collection_response['response']['data']['shows']) == 7
예제 #25
0
    def test_get_artists(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/all_artists.json') as f:
            all_artists_json = json.load(f)
        requests_mock.post(api.base_url + "artists/all", json=all_artists_json)

        artists_response = api.get_artists()
        assert artists_response['response']['count'] == 5
        assert len(artists_response['response']['data']) == 5
        assert artists_response['response']['data']['1']['artistid'] == 1
예제 #26
0
    def test_get_all_people(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/all_people.json') as f:
            all_people_json = json.load(f)
        requests_mock.post(api.base_url + "people/all", json=all_people_json)

        people_response = api.get_all_people()
        assert people_response['response']['count'] == 12
        assert len(people_response['response']['data']) == 12
        assert people_response['response']['data'][0]['personid'] == 5710
예제 #27
0
    def test_get_jamchart(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/get_jamchart.json') as f:
            get_jamchart_json = json.load(f)
        requests_mock.post(api.base_url + "jamcharts/get",
                           json=get_jamchart_json)

        jamchart_response = api.get_jamchart(7)
        assert jamchart_response['response']['data']['songid'] == 7
        assert len(jamchart_response['response']['data']['entries']) == 7
예제 #28
0
    def test_get_show_links(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        with open('tests/data/get_show_links.json') as f:
            get_show_links_json = json.load(f)
        requests_mock.post(api.base_url + "shows/links",
                           json=get_show_links_json)

        show_links_response = api.get_show_links(1394573037)
        assert show_links_response['response']['count'] == 4
        assert len(show_links_response['response']['data']) == 4
        assert show_links_response['response']['data'][0]['type'] == "Photos"
예제 #29
0
    def test_get_blogs(self):
        api = PhishNetAPI()
        blogs_response = api.get_blogs(year=2009)

        assert blogs_response['error_code'] == 0
        assert blogs_response['response']['count'] == len(
            blogs_response['response']['data'])

        with pytest.raises(ParamValidationError):
            api.get_blogs(year=2008)
            api.get_blogs(year=2020)
예제 #30
0
    def test_get_appearances(self):
        api = PhishNetAPI()
        appearances_response = api.get_appearances(79)

        assert appearances_response['error_code'] == 0
        assert appearances_response['response']['count'] == len(
            appearances_response['response']['data'])
        assert appearances_response['response']['data'][0]['personid'] == 79

        with pytest.raises(ParamValidationError):
            api.get_appearances(79, 1982)