예제 #1
0
 def test_get_real_social_auth_no_social(self):
     """
     Test that if a UserSocialAuth object hasn't been attached to the pipeline as
     `social`, we return none
     """
     request = mock.MagicMock(session={'running_pipeline': {'kwargs': {}}})
     real_social = pipeline.get_real_social_auth_object(request)
     assert real_social is None
예제 #2
0
 def test_get_real_social_auth_no_pipeline(self):
     """
     Test that if there's no running pipeline, we return None when looking
     for a database-backed UserSocialAuth object.
     """
     request = mock.MagicMock(session={})
     real_social = pipeline.get_real_social_auth_object(request)
     assert real_social is None
예제 #3
0
    def test_get_real_social_auth(self):
        """
        Test that trying to get a database-backed UserSocialAuth from an existing
        instance returns correctly.
        """
        request = mock.MagicMock()
        pipeline_partial = {'kwargs': {'social': self.social_auth}}

        with mock.patch('common.djangoapps.third_party_auth.pipeline.get'
                        ) as get_pipeline:
            get_pipeline.return_value = pipeline_partial
            real_social = pipeline.get_real_social_auth_object(request)
            assert real_social == self.social_auth
예제 #4
0
    def test_get_real_social_auth_from_dict(self):
        """
        Test that we can use a dictionary with a UID entry to retrieve a
        database-backed UserSocialAuth object.
        """
        request = mock.MagicMock()
        pipeline_partial = {'kwargs': {'social': {'uid': 'fake uid'}}}

        with mock.patch('common.djangoapps.third_party_auth.pipeline.get'
                        ) as get_pipeline:
            get_pipeline.return_value = pipeline_partial
            real_social = pipeline.get_real_social_auth_object(request)
            assert real_social == self.social_auth