From 7be7b50ba9ec5e115b2a5af5a801c1c4f73febea Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Fri, 12 Dec 2014 21:45:23 -0500 Subject: [PATCH 1/3] Mock out the underlying segment-io call. TE-532 --- common/djangoapps/third_party_auth/tests/specs/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/djangoapps/third_party_auth/tests/specs/base.py b/common/djangoapps/third_party_auth/tests/specs/base.py index 3c34754931..1ffd450f1a 100644 --- a/common/djangoapps/third_party_auth/tests/specs/base.py +++ b/common/djangoapps/third_party_auth/tests/specs/base.py @@ -424,6 +424,7 @@ class IntegrationTest(testutil.TestCase, test.TestCase): request, strategy = self.get_request_and_strategy( auth_entry=pipeline.AUTH_ENTRY_LOGIN, redirect_uri='social:complete') strategy.backend.auth_complete = mock.MagicMock(return_value=self.fake_auth_complete(strategy)) + pipeline.analytics.track = mock.MagicMock() request.user = self.create_user_models_for_existing_account( strategy, 'user@example.com', 'password', self.get_username(), skip_social_auth=True) @@ -558,6 +559,7 @@ class IntegrationTest(testutil.TestCase, test.TestCase): request, strategy = self.get_request_and_strategy( auth_entry=pipeline.AUTH_ENTRY_LOGIN, redirect_uri='social:complete') strategy.backend.auth_complete = mock.MagicMock(return_value=self.fake_auth_complete(strategy)) + pipeline.analytics.track = mock.MagicMock() user = self.create_user_models_for_existing_account( strategy, 'user@example.com', 'password', self.get_username()) self.assert_social_auth_exists_for_user(user, strategy) From 352fce6e02ef4a42f74358c98e7f84bf7297f8fd Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Sat, 13 Dec 2014 19:28:15 -0500 Subject: [PATCH 2/3] Fix another analytics.init secret error message (noise). --- lms/djangoapps/shoppingcart/tests/test_models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index 83d412c4fc..89f0e3a708 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -3,6 +3,7 @@ Tests for the Shopping Cart Models """ from decimal import Decimal import datetime +import os import smtplib from boto.exception import BotoServerError # this is a super-class of SESError and catches connection errors @@ -233,7 +234,10 @@ class OrderTest(ModuleStoreTestCase): item = CertificateItem.add_to_order(cart, self.course_key, self.cost, 'honor') # course enrollment object should be created but still inactive self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course_key)) - cart.purchase() + # the analytics client pipes output to stderr when using the default client + devnull = open(os.devnull, 'w') + with patch('sys.stderr', devnull): + cart.purchase() self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key)) # test e-mail sending From e0f83ded6d2ec9ab3bb842817e9e6ebce003e1e9 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Sat, 13 Dec 2014 20:02:53 -0500 Subject: [PATCH 3/3] Pipe analytics client output to stdout instead of devnull. --- lms/djangoapps/shoppingcart/tests/test_models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/shoppingcart/tests/test_models.py b/lms/djangoapps/shoppingcart/tests/test_models.py index 89f0e3a708..4718d25e81 100644 --- a/lms/djangoapps/shoppingcart/tests/test_models.py +++ b/lms/djangoapps/shoppingcart/tests/test_models.py @@ -3,7 +3,7 @@ Tests for the Shopping Cart Models """ from decimal import Decimal import datetime -import os +import sys import smtplib from boto.exception import BotoServerError # this is a super-class of SESError and catches connection errors @@ -235,8 +235,7 @@ class OrderTest(ModuleStoreTestCase): # course enrollment object should be created but still inactive self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course_key)) # the analytics client pipes output to stderr when using the default client - devnull = open(os.devnull, 'w') - with patch('sys.stderr', devnull): + with patch('sys.stderr', sys.stdout.write): cart.purchase() self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course_key))