Fix failing unit tests in internals/ and framework/.

This commit is contained in:
Jason Robbins 2021-09-22 14:41:06 -04:00
Родитель 18210d537d
Коммит a6373d2add
3 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -328,7 +328,7 @@ class APIHandlerTests(testing_config.CustomTestCase):
with test_app.test_request_context('/path'):
actual = self.handler.defensive_jsonify(handler_data)
actual_sent_text = str(actual.response[0])
actual_sent_text = actual.response[0].decode()
self.assertTrue(actual_sent_text.startswith(basehandlers.XSSI_PREFIX))
self.assertIn(json.dumps(handler_data), actual_sent_text)
@ -631,4 +631,4 @@ class FlaskHandlerTests(testing_config.CustomTestCase):
form_data = {'token': xsrf.generate_token('user2@example.com')}
with test_app.test_request_context('/test', data=form_data):
with self.assertRaises(werkzeug.exceptions.BadRequest):
self.handler.require_xsrf_token()
self.handler.require_xsrf_token()

Просмотреть файл

@ -73,7 +73,8 @@ def generate_token(user_email, token_time=None):
digester.update(DELIMITER)
digester.update(token_time)
digest = digester.digest()
token = base64.urlsafe_b64encode(digest+ DELIMITER + token_time)
binary_token = base64.urlsafe_b64encode(digest+ DELIMITER + token_time)
token = binary_token.decode()
return token

Просмотреть файл

@ -310,7 +310,7 @@ class FeatureStarTest(testing_config.CustomTestCase):
self.assertEqual([], actual)
def test_get_user_stars__some_stars(self):
"""User has starred two features."""
"""User has starred three features."""
email = 'user5@example.com'
feature_1_id = self.feature_1.key.integer_id()
feature_2_id = self.feature_2.key.integer_id()
@ -321,8 +321,9 @@ class FeatureStarTest(testing_config.CustomTestCase):
notifier.FeatureStar.set_star(email, feature_2_id)
actual = notifier.FeatureStar.get_user_stars(email)
self.assertCountEqual(
[feature_1_id, feature_2_id],
self.assertEqual(
sorted([feature_1_id, feature_2_id, feature_3_id],
reverse=True),
actual)
def test_get_feature_starrers__no_stars(self):