From 334db5e47aad793b8452df30077fc8ded335b40f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Jan 2019 14:26:02 -0600 Subject: [PATCH 1/5] Update celery and kombu for Py3.7 --- requirements.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index fc35b1dd..fa9f5fb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -71,9 +71,8 @@ python-memcached # }}} # {{{ A task queue, used to execute long-running tasks -celery==4.1.0 -# https://github.com/celery/kombu/issues/870 -kombu==4.1.0 +celery==4.2.1 +kombu==4.2.2-post1 django-celery-results==1.0.1 # }}} -- GitLab From 5786aa4ee076b6233bd1698810281dffb931263b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Jan 2019 15:30:36 -0600 Subject: [PATCH 2/5] Fix test typo 'calender' --- tests/test_calendar.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_calendar.py b/tests/test_calendar.py index 7d65a6dd..a29e5531 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -602,7 +602,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): self.addCleanup(factories.EventFactory.reset_sequence) - def get_course_calender_view(self, course_identifier=None): + def get_course_calendar_view(self, course_identifier=None): course_identifier = course_identifier or self.get_default_course_identifier() return self.c.get(self.get_course_calender_url(course_identifier)) @@ -616,12 +616,12 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): "course.utils.CoursePageContext.has_permission" ) as mock_has_pperm: mock_has_pperm.return_value = False - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 403) def test_neither_events_nor_event_file(self): self.mock_get_now_or_fake_time.return_value = self.default_faked_now - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) self.assertResponseContextEqual(resp, "events_json", '[]') self.assertResponseContextEqual(resp, "event_info_list", []) @@ -636,7 +636,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): kind=self.default_event_kind, course=self.course, time=self.default_event_time + timedelta(hours=1)) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) events_json = json.loads(resp.context["events_json"]) @@ -664,7 +664,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): shown_in_calendar=False, time=self.default_event_time + timedelta(hours=1)) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) events_json = json.loads(resp.context["events_json"]) @@ -681,7 +681,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): kind=self.default_event_kind, course=self.course, time=self.default_event_time, end_time=self.default_event_time + timedelta(hours=1)) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) events_json = json.loads(resp.context["events_json"]) @@ -702,7 +702,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): self.course.end_date = (self.default_faked_now - timedelta(weeks=1)).date() self.course.save() - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) self.assertResponseContextEqual(resp, "events_json", '[]') @@ -715,7 +715,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): self.course.end_date = (self.default_faked_now + timedelta(weeks=1)).date() self.course.save() - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertEqual(resp.status_code, 200) self.assertResponseContextEqual(resp, "events_json", '[]') @@ -727,7 +727,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): # make sure it works self.switch_to_fake_commit_sha() - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertResponseContextEqual(resp, "events_json", '[]') self.assertResponseContextEqual(resp, "event_info_list", []) @@ -746,7 +746,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): kind=self.default_event_kind, course=self.course, time=self.default_event_time, ordinal=2) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 2) @@ -810,7 +810,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): time=test_start_time, ordinal=None) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 3) @@ -858,7 +858,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): lecture3_start_time + timedelta(minutes=5)) # no EventInfo object - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() self.assertResponseContextEqual(resp, "event_info_list", []) def test_events_file_with_events_test3(self): @@ -871,7 +871,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): time=self.default_event_time, end_time=exam_end_time) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 1) @@ -907,7 +907,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): kind=self.default_event_kind, course=self.course, time=lecture3_start_time, ordinal=3) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 2) @@ -924,7 +924,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): lecture2_evt.end_time = lecture2_end_time lecture2_evt.save() - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 2) @@ -949,7 +949,7 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): lecture2_end_time += timedelta(hours=1) - resp = self.get_course_calender_view() + resp = self.get_course_calendar_view() events_json = json.loads(resp.context["events_json"]) self.assertEqual(len(events_json), 2) -- GitLab From eba405cec1ef9daddc0e27d61291090690468e84 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Jan 2019 18:29:35 -0600 Subject: [PATCH 3/5] Correctly set fake time in test_events_file_with_events_test1 --- tests/test_calendar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_calendar.py b/tests/test_calendar.py index a29e5531..70cefc16 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -734,6 +734,8 @@ class ViewCalendarTest(SingleCourseTestMixin, HackRepoMixin, TestCase): def test_events_file_with_events_test1(self): self.switch_to_fake_commit_sha() + self.mock_get_now_or_fake_time.return_value = ( + self.default_event_time - timedelta(days=5)) # lecture 1 lecture1_start_time = self.default_event_time - timedelta(weeks=1) -- GitLab From 3dabea253dbf16465c694356a77e0049e53980cd Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Jan 2019 18:32:13 -0600 Subject: [PATCH 4/5] Fix invalid escape sequence in test_versioning --- tests/test_versioning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 9856709b..8e7421e6 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -985,7 +985,7 @@ class GetCommitMessageAsHtmlTest(VersioningRepoMixin, SingleCourseTestMixin, repo_dict = { commit_sha_1: FakeCommit("a_commit", message=b"test a > b "), commit_sha_2: FakeCommit("another_commit", message=b"

test

"), - commit_sha_3: FakeCommit("another_commit", message=b"abc\uDC80"), + commit_sha_3: FakeCommit("another_commit", message=b"abc\\uDC80"), } repo = mock.MagicMock() repo.__getitem__.side_effect = repo_dict.__getitem__ -- GitLab From 7c398df25afe3e7c96625a8d16b0553267745e47 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 21 Jan 2019 18:32:36 -0600 Subject: [PATCH 5/5] Fix test suite failures when running in a user account with an SSH key --- tests/test_versioning.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 8e7421e6..dd964241 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -288,7 +288,12 @@ class ParamikoSSHVendorTest(unittest.TestCase): def test_invalid(self): from paramiko.ssh_exception import AuthenticationException - expected_error_msg = "Authentication failed" + expected_error_msgs = [ + "Authentication failed", + + # Raised when run in a user account that has + # an (encrypted) key file in $HOME/.ssh. + "Private key file is encrypted"] with self.assertRaises(AuthenticationException) as cm: # This is also used to ensure paramiko.client.MissingHostKeyPolicy # is added to the client @@ -297,7 +302,8 @@ class ParamikoSSHVendorTest(unittest.TestCase): command="git-upload-pack '/bar/baz'", username=None, port=None) - self.assertIn(expected_error_msg, str(cm.exception)) + self.assertTrue(any( + msg in str(cm.exception) for msg in expected_error_msgs)) with self.assertRaises(AuthenticationException) as cm: self.ssh_vendor.run_command( @@ -305,7 +311,8 @@ class ParamikoSSHVendorTest(unittest.TestCase): command="git-upload-pack '/bar/baz'", username="me", port=22) - self.assertIn(expected_error_msg, str(cm.exception)) + self.assertTrue(any( + msg in str(cm.exception) for msg in expected_error_msgs)) expected_error_msg = "Bad authentication type" -- GitLab