daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/tests/test_views.py b/tests/test_views.py
  2. index d4db87f..1216517 100644
  3. --- a/tests/test_views.py
  4. +++ b/tests/test_views.py
  5. @@ -976,6 +976,12 @@ class TestCourseEnrollmentView(TestCase):
  6.          """
  7.          assert self.client.login(username=self.user.username, password="QWERTY")
  8.  
  9. +    def _setup_course_catalog(self, course_catalog_client_mock):
  10. +        catalog_instance = course_catalog_client_mock.return_value
  11. +        catalog_instance.get_course_run.return_value = {
  12. +            'level_type': 'Type 1',
  13. +        }
  14. +
  15.      @mock.patch('enterprise.views.render', side_effect=fake_render)
  16.      @mock.patch('enterprise.views.configuration_helpers')
  17.      @mock.patch('enterprise.tpa_pipeline.get_enterprise_customer_for_request')
  18. @@ -999,10 +1005,7 @@ class TestCourseEnrollmentView(TestCase):
  19.              configuration_helpers_mock,
  20.              render_to_response_mock,    # pylint: disable=unused-argument
  21.      ):
  22. -        catalog_instance = course_catalog_client_mock.return_value
  23. -        catalog_instance.get_course_run.return_value = {
  24. -            'level_type': 'Type 1',
  25. -        }
  26. +        self._setup_course_catalog(course_catalog_client_mock)
  27.          logo_mock = mock.MagicMock()
  28.          logo_mock.url = 'logo.png'
  29.          organizations_helpers_mock.get_organization.return_value = {
  30. @@ -1097,10 +1100,7 @@ class TestCourseEnrollmentView(TestCase):
  31.              configuration_helpers_mock,
  32.              render_to_response_mock,    # pylint: disable=unused-argument
  33.      ):
  34. -        catalog_instance = course_catalog_client_mock.return_value
  35. -        catalog_instance.get_course_run.return_value = {
  36. -            'level_type': 'Type 1',
  37. -        }
  38. +        self._setup_course_catalog(course_catalog_client_mock)
  39.          organizations_helpers_mock.get_organization.return_value = mock.MagicMock()
  40.          course_id = self.demo_course_id
  41.          configuration_helpers_mock.get_value.return_value = 'edX'
  42. @@ -1193,10 +1193,7 @@ class TestCourseEnrollmentView(TestCase):
  43.          Verify that the context of the enterprise course enrollment page has
  44.          empty course start date if course details has no start date.
  45.          """
  46. -        catalog_instance = course_catalog_client_mock.return_value
  47. -        catalog_instance.get_course_run.return_value = {
  48. -            'level_type': 'Type 1',
  49. -        }
  50. +        self._setup_course_catalog(course_catalog_client_mock)
  51.          organizations_helpers_mock.get_organization.return_value = mock.MagicMock()
  52.          course_id = self.demo_course_id
  53.          configuration_helpers_mock.get_value.return_value = 'edX'
  54. @@ -1543,10 +1540,7 @@ class TestCourseEnrollmentView(TestCase):
  55.              configuration_helpers_mock,
  56.              render_to_response_mock,    # pylint: disable=unused-argument
  57.      ):
  58. -        catalog_instance = course_catalog_client_mock.return_value
  59. -        catalog_instance.get_course_run.return_value = {
  60. -            'level_type': 'Type 1',
  61. -        }
  62. +        self._setup_course_catalog(course_catalog_client_mock)
  63.          organizations_helpers_mock.get_organization.return_value = mock.MagicMock()
  64.          course_id = self.demo_course_id
  65.          configuration_helpers_mock.get_value.return_value = 'edX'
  66. @@ -1684,10 +1678,7 @@ class TestCourseEnrollmentView(TestCase):
  67.              _unused_render_to_response_mock,
  68.      ):
  69.          # Set up course catalog API client
  70. -        catalog_instance = course_catalog_client_mock.return_value
  71. -        catalog_instance.get_course_run.return_value = {
  72. -            'level_type': 'Type 1',
  73. -        }
  74. +        self._setup_course_catalog(course_catalog_client_mock)
  75.  
  76.          # Set up organizations API client
  77.          logo_mock = mock.MagicMock()
  78. @@ -1797,10 +1788,7 @@ class TestCourseEnrollmentView(TestCase):
  79.              _unused_render_to_response_mock,
  80.      ):
  81.          # Set up course catalog API client
  82. -        catalog_instance = course_catalog_client_mock.return_value
  83. -        catalog_instance.get_course_run.return_value = {
  84. -            'level_type': 'Type 1',
  85. -        }
  86. +        self._setup_course_catalog(course_catalog_client_mock)
  87.  
  88.          # Set up organizations API client
  89.          organizations_helpers_mock.get_organization.return_value = None
  90. @@ -1905,10 +1893,7 @@ class TestCourseEnrollmentView(TestCase):
  91.              _unused_render_to_response_mock,
  92.      ):
  93.          # Set up course catalog API client
  94. -        catalog_instance = course_catalog_client_mock.return_value
  95. -        catalog_instance.get_course_run.return_value = {
  96. -            'level_type': 'Type 1',
  97. -        }
  98. +        self._setup_course_catalog(course_catalog_client_mock)
  99.  
  100.          # Set up organizations API client
  101.          organizations_helpers_mock.get_organization.side_effect = ValueError
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top