Exemple #1
0
    def test_create_user_add_failed(self):
        self.run_api_call.return_value = {'success' : False,
                                          'reason'  : "Mocked it up to fail, duh!",
                                          }

        testuser = {'email': sentinel.email,
                    'firstname': sentinel.givenName,
                    'lastname': sentinel.surname,
                    }
        with self.assertRaises(api_interface.ManipulateUserFailed):
            api_interface.create_user(sentinel.api_root,
                                      testuser)
Exemple #2
0
    def test_create_user_add_failed(self):
        self.run_api_call.return_value = {
            'success': False,
            'reason': "Mocked it up to fail, duh!",
        }

        testuser = {
            'email': sentinel.email,
            'firstname': sentinel.givenName,
            'lastname': sentinel.surname,
        }
        with self.assertRaises(api_interface.ManipulateUserFailed):
            api_interface.create_user(sentinel.api_root, testuser)
Exemple #3
0
    def test_create_run_api_call_exception(self):
        self.run_api_call.side_effect = Exception("DEADBEEF")

        testuser = {'email': sentinel.email,
                    'firstname': sentinel.givenName,
                    'lastname': sentinel.surname,
                    }

        with self.assertRaises(api_interface.ManipulateUserFailed) as cm:
            api_interface.create_user(sentinel.api_root,testuser)
                                      
        the_exception = cm.exception
        self.assertEqual(str(the_exception), "DEADBEEF")
Exemple #4
0
    def test_create_run_api_call_exception(self):
        self.run_api_call.side_effect = Exception("DEADBEEF")

        testuser = {
            'email': sentinel.email,
            'firstname': sentinel.givenName,
            'lastname': sentinel.surname,
        }

        with self.assertRaises(api_interface.ManipulateUserFailed) as cm:
            api_interface.create_user(sentinel.api_root, testuser)

        the_exception = cm.exception
        self.assertEqual(str(the_exception), "DEADBEEF")
Exemple #5
0
    def test_create_succeeds(self):
        self.run_api_call.return_value = {'success': True,
                                          'server_generated_username': sentinel.testuser}

        testuser = {'email': sentinel.email,
                    'firstname': sentinel.givenName,
                    'lastname': sentinel.surname,
                    }
        result = api_interface.create_user(sentinel.api_root,testuser)
                                           
        self.assertEqual(result['server_generated_username'], sentinel.testuser)

        args, _ = self.run_api_call.call_args

        self.assertIs(sentinel.api_root, args[0])
        assert sentinel.email in args[2].values()
        assert sentinel.givenName in args[2].values()
        assert sentinel.surname in args[2].values()
Exemple #6
0
    def test_create_succeeds(self):
        self.run_api_call.return_value = {
            'success': True,
            'server_generated_username': sentinel.testuser
        }

        testuser = {
            'email': sentinel.email,
            'firstname': sentinel.givenName,
            'lastname': sentinel.surname,
        }
        result = api_interface.create_user(sentinel.api_root, testuser)

        self.assertEqual(result['server_generated_username'],
                         sentinel.testuser)

        args, _ = self.run_api_call.call_args

        self.assertIs(sentinel.api_root, args[0])
        assert sentinel.email in args[2].values()
        assert sentinel.givenName in args[2].values()
        assert sentinel.surname in args[2].values()