From 9c92bd96ed70e8b3af968279c0b57bdf216e58e6 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Thu, 10 Oct 2019 15:22:07 -0400 Subject: [PATCH] Fix assertions failing under Python 3 BOM-668 (#21978) --- common/djangoapps/terrain/stubs/http.py | 2 +- openedx/core/djangoapps/schedules/resolvers.py | 2 +- .../user_authn/views/tests/test_views.py | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/djangoapps/terrain/stubs/http.py b/common/djangoapps/terrain/stubs/http.py index 24ed0e7194..ff89f69b1f 100644 --- a/common/djangoapps/terrain/stubs/http.py +++ b/common/djangoapps/terrain/stubs/http.py @@ -104,7 +104,7 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler, object): Retrieve the request POST parameters from the client as a dictionary. If no POST parameters can be interpreted, return an empty dict. """ - contents = self.request_content.decode() + contents = self.request_content # The POST dict will contain a list of values for each key. # None of our parameters are lists, however, so we map [val] --> val diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py index aef414639d..f35787eb16 100644 --- a/openedx/core/djangoapps/schedules/resolvers.py +++ b/openedx/core/djangoapps/schedules/resolvers.py @@ -340,7 +340,7 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver): experience_filter = Q(experience__experience_type=ScheduleExperience.EXPERIENCES.course_updates) def schedules_for_bin(self): - week_num = abs(self.day_offset) / 7 + week_num = abs(self.day_offset) // 7 schedules = self.get_schedules_with_target_date_by_bin_and_orgs( order_by='enrollment__course', ) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_views.py b/openedx/core/djangoapps/user_authn/views/tests/test_views.py index d1b1f97797..9fc4988957 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_views.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_views.py @@ -3,6 +3,7 @@ from __future__ import absolute_import +import json import logging import re from http.cookies import SimpleCookie @@ -125,8 +126,11 @@ class UserAccountUpdateTest(CacheIsolationTestCase, UrlResetMixin): self.client.logout() # Verify that the new password can be used to log in - result = self.client.login(username=self.USERNAME, password=self.NEW_PASSWORD) - self.assertTrue(result) + login_url = reverse('login_post') + response = self.client.post(login_url, {'email': self.OLD_EMAIL, 'password': self.NEW_PASSWORD}) + assert response.status_code == 200 + response_dict = json.loads(response.content.decode('utf-8')) + assert response_dict['success'] # Try reusing the activation link to change the password again # Visit the activation link again. @@ -141,8 +145,10 @@ class UserAccountUpdateTest(CacheIsolationTestCase, UrlResetMixin): self.assertFalse(result) # Verify that the new password continues to be valid - result = self.client.login(username=self.USERNAME, password=self.NEW_PASSWORD) - self.assertTrue(result) + response = self.client.post(login_url, {'email': self.OLD_EMAIL, 'password': self.NEW_PASSWORD}) + assert response.status_code == 200 + response_dict = json.loads(response.content.decode('utf-8')) + assert response_dict['success'] def test_password_change_failure(self): with mock.patch('openedx.core.djangoapps.user_api.accounts.api.request_password_change',