コード例 #1
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
コード例 #2
0
    def test_update_show_attendance(self, requests_mock):
        api = PhishNetAPI('apikey123456789test1')
        api.authkey = 'B6386A2485D94C73DAA'
        api.uid = 80
        with open('tests/data/add_attendance.json') as f:
            add_attendance_json = json.load(f)
        requests_mock.post(api.base_url + "attendance/add",
                           json=add_attendance_json)

        update_attendance_response = api.update_show_attendance(
            api.uid, showid=1252691618, update='add')
        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 = update_attendance_response['response']['data'][
            'shows_seen']
        assert shows_seen == '63'

        with open('tests/data/remove_attendance.json') as f:
            remove_attendance_json = json.load(f)
        requests_mock.post(api.base_url + "attendance/remove",
                           json=remove_attendance_json)

        update_attendance_response = api.update_show_attendance(
            api.uid, showid=1252691618, update='remove')
        assert update_attendance_response[
            'error_message'] == "Successfully removed 1997-11-30"
        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
        assert update_attendance_response['response']['data'][
            'shows_seen'] == str(int(shows_seen) - 1)