'Create mock function to test ssl login decorator'

@skip_unless_lms
def test_ssl_login_decorator(self):

    dec_mock = external_auth_views.ssl_login_shortcut(self.mock)
    with self._create_normal_request(self.MOCK_URL) as request:
        dec_mock(request)
    self.assertTrue(self.mock.called)
    self.assertEqual(0, len(ExternalAuthMap.objects.all()))
    self.mock.reset_mock()
    with self._create_ssl_request(self.MOCK_URL) as request:
        dec_mock(request)
    self.assertFalse(self.mock.called)
    self.assertEqual(1, len(ExternalAuthMap.objects.all()))
    self.mock.reset_mock()
    with self._create_ssl_request(self.MOCK_URL) as request:
        request.user = UserFactory()
        dec_mock(request)
    self.assertTrue(self.mock.called)
