Last active
April 13, 2022 13:50
-
-
Save YouzhiL/cb0810c811fec50c5f6dbb38640c0e92 to your computer and use it in GitHub Desktop.
current errors when working on LB-119
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
________________ APICompatTestCase.test_complete_workflow_json _________________ | |
self = <listenbrainz.tests.integration.test_api_compat.APICompatTestCase testMethod=test_complete_workflow_json> | |
def test_complete_workflow_json(self): | |
""" Integration test for complete workflow to submit a listen using Last.fm compat api """ | |
data = { | |
'method': 'auth.gettoken', | |
'api_key': self.lfm_user.api_key, | |
'format': 'json', | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
token = r.json['token'] | |
# login as user | |
with self.client.session_transaction() as session: | |
session['_user_id'] = self.lb_user['login_id'] | |
session['_fresh'] = True | |
r = self.client.post( | |
url_for('api_compat.api_auth_approve'), | |
data=f"token={token}", | |
headers={'Content-Type': 'application/x-www-form-urlencoded'} | |
) | |
self.assert200(r) | |
data = { | |
'method': 'auth.getsession', | |
'api_key': self.lfm_user.api_key, | |
'token': token, | |
'format': 'json' | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
sk = r.json['session']['key'] | |
data = { | |
'method': 'track.scrobble', | |
'api_key': self.lfm_user.api_key, | |
'sk': sk, | |
'format': 'json', | |
'artist[0]': 'Kishore Kumar', | |
'track[0]': 'Saamne Ye Kaun Aya', | |
'album[0]': 'Jawani Diwani', | |
'duration[0]': 300, | |
'timestamp[0]': int(time.time()), | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
expected = { | |
"scrobbles": { | |
"scrobble": { | |
"track": { | |
"#text": data["track[0]"], | |
"corrected": "0" | |
}, | |
"artist": { | |
"#text": data["artist[0]"], | |
"corrected": "0" | |
}, | |
"album": { | |
"#text": data["album[0]"], | |
"corrected": "0" | |
}, | |
"albumArtist": { | |
"#text": data["artist[0]"], | |
"corrected": "0" | |
}, | |
"timestamp": str(data["timestamp[0]"]), | |
"ignoredMessage": { | |
"code": "0" | |
} | |
}, | |
"accepted": "1", | |
"ignored": "0" | |
} | |
} | |
> self.assertEqual(expected, r.json) | |
E AssertionError: {'scrobbles': {'scrobble': {'track': {'#tex[306 chars]'0'}} != {'error': 6, 'message': 'duration type inva[17 chars]ted'} | |
E Diff is 776 characters long. Set self.maxDiff to None to see it. | |
listenbrainz/tests/integration/test_api_compat.py:125: AssertionError | |
_____________________ APICompatTestCase.test_record_listen _____________________ | |
self = <listenbrainz.tests.integration.test_api_compat.APICompatTestCase testMethod=test_record_listen> | |
def test_record_listen(self): | |
""" Tests if listen is recorded correctly if valid information is provided. """ | |
token = Token.generate(self.lfm_user.api_key) | |
token.approve(self.lfm_user.name) | |
session = Session.create(token) | |
timestamp = int(time.time()) | |
data = { | |
'method': 'track.scrobble', | |
'api_key': self.lfm_user.api_key, | |
'sk': session.sid, | |
'artist[0]': 'Kishore Kumar', | |
'track[0]': 'Saamne Ye Kaun Aya', | |
'album[0]': 'Jawani Diwani', | |
'duration[0]': 300, | |
'timestamp[0]': timestamp, | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
self.assertEqual(r.headers["Content-type"], "application/xml; charset=utf-8") | |
response = xmltodict.parse(r.data) | |
> self.assertEqual(response['lfm']['@status'], 'ok') | |
E AssertionError: 'failed' != 'ok' | |
E - failed | |
E + ok | |
listenbrainz/tests/integration/test_api_compat.py:267: AssertionError | |
----------------------------- Captured stderr call ----------------------------- | |
2022-04-13 12:51:50,807 listenbrainz.webserver INFO Flask application created! | |
------------------------------ Captured log call ------------------------------- | |
INFO listenbrainz.webserver:__init__.py:200 Flask application created! | |
____________ APICompatTestCase.test_record_listen_multiple_listens _____________ | |
self = <listenbrainz.tests.integration.test_api_compat.APICompatTestCase testMethod=test_record_listen_multiple_listens> | |
def test_record_listen_multiple_listens(self): | |
""" Tests if multiple listens get recorded correctly in case valid information | |
is provided. | |
""" | |
token = Token.generate(self.lfm_user.api_key) | |
token.approve(self.lfm_user.name) | |
session = Session.create(token) | |
timestamp = int(time.time()) | |
data = { | |
'method': 'track.scrobble', | |
'api_key': self.lfm_user.api_key, | |
'sk': session.sid, | |
'artist[0]': 'Kishore Kumar', | |
'track[0]': 'Saamne Ye Kaun Aya', | |
'album[0]': 'Jawani Diwani', | |
'duration[0]': 300, | |
'timestamp[0]': timestamp, | |
'artist[1]': 'Fifth Harmony', | |
'track[1]': 'Deliver', | |
'duration[1]': 200, | |
'timestamp[1]': timestamp+300, | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
response = xmltodict.parse(r.data) | |
> self.assertEqual(response['lfm']['@status'], 'ok') | |
E AssertionError: 'failed' != 'ok' | |
E - failed | |
E + ok | |
listenbrainz/tests/integration/test_api_compat.py:327: AssertionError | |
----------------------------- Captured stderr call ----------------------------- | |
2022-04-13 12:51:53,539 listenbrainz.webserver INFO Flask application created! | |
------------------------------ Captured log call ------------------------------- | |
INFO listenbrainz.webserver:__init__.py:200 Flask application created! | |
_______________ APICompatTestCase.test_record_listen_now_playing _______________ | |
self = <listenbrainz.tests.integration.test_api_compat.APICompatTestCase testMethod=test_record_listen_now_playing> | |
def test_record_listen_now_playing(self): | |
""" Tests if listen of type 'nowplaying' is recorded correctly | |
if valid information is provided. | |
""" | |
token = Token.generate(self.lfm_user.api_key) | |
token.approve(self.lfm_user.name) | |
session = Session.create(token) | |
data = { | |
'method': 'track.updateNowPlaying', | |
'api_key': self.lfm_user.api_key, | |
'sk': session.sid, | |
'artist[0]': 'Kishore Kumar', | |
'track[0]': 'Saamne Ye Kaun Aya', | |
'album[0]': 'Jawani Diwani', | |
'duration[0]': 300, | |
'timestamp[0]': int(time.time()), | |
} | |
r = self.client.post(url_for('api_compat.api_methods'), data=data) | |
self.assert200(r) | |
response = xmltodict.parse(r.data) | |
> self.assertEqual(response['lfm']['@status'], 'ok') | |
E AssertionError: 'failed' != 'ok' | |
E - failed | |
E + ok | |
listenbrainz/tests/integration/test_api_compat.py:157: AssertionError | |
----------------------------- Captured stderr call ----------------------------- | |
2022-04-13 12:51:56,109 listenbrainz.webserver INFO Flask application created! | |
------------------------------ Captured log call ------------------------------- | |
INFO listenbrainz.webserver:__init__.py:200 Flask application created! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment