Example #1
0
    def test_configure_user__User_Does_Not_Exists(self, _call_wisp_api):
        """ Test Case - """

        _call_wisp_api.return_value = {'results': []}
        user = Mock(username='******')
        x = WhartonRemoteUserBackend()
        
        with self.assertRaises(PermissionDenied) as cm:
            x.configure_user(user)
        klass_name = cm.exception.__class__.__name__
        self.assertEqual(klass_name, 'PermissionDenied')
Example #2
0
    def test_configure_user__User_Exists_And_Is_Apart_of_Wharton(self, _call_wisp_api):
        """ Test Case - configure user will add user to django model """

        _call_wisp_api.return_value = {'results': [{'first_name': 'Tester', 'last_name': 'Dude', 'email': '*****@*****.**' }]} 
        user = Mock(username='******') 
        x = WhartonRemoteUserBackend()
        x.configure_user(user)
 
        self.assertFalse(user.is_staff)
        self.assertEqual(user.last_name, 'Dude')
        self.assertEqual(user.first_name, 'Tester')
        self.assertEqual(user.email, '*****@*****.**')
        self.assertTrue(user.save.called)