def test_save_no_errors(monkeypatch):
    def mock_call_api(self):
        pass
    monkeypatch.setattr(User, '_call_api', mock_call_api)
    user = User()

    assert user.save() is None
Example #2
0
def test_save_no_errors(monkeypatch):
    def mock_call_api(self):
        pass

    monkeypatch.setattr(User, '_call_api', mock_call_api)
    user = User()

    assert user.save() is None
def test_save_requirement_error(monkeypatch):
    def mock_call_api(self):
        raise mock_errors.DuplicateEntry
    monkeypatch.setattr(User, '_call_api', mock_call_api)
    monkeypatch.setattr(
        freeipa_community_portal.model.user, 'errors', mock_errors)
    user = User()
    assert user.save() == 'test_dup'
def test_save_validation_error(monkeypatch):
    def mock_call_api(self):
        raise mock_errors.ValidationError
    monkeypatch.setattr(User, '_call_api', mock_call_api)
    monkeypatch.setattr(
        freeipa_community_portal.model.user, 'errors', mock_errors)
    user = User()
    assert user.save() == 'test_valid'
Example #5
0
def test_save_requirement_error(monkeypatch):
    def mock_call_api(self):
        raise mock_errors.DuplicateEntry

    monkeypatch.setattr(User, '_call_api', mock_call_api)
    monkeypatch.setattr(freeipa_community_portal.model.user, 'errors',
                        mock_errors)
    user = User()
    assert user.save() == 'test_dup'
Example #6
0
def test_save_validation_error(monkeypatch):
    def mock_call_api(self):
        raise mock_errors.ValidationError

    monkeypatch.setattr(User, '_call_api', mock_call_api)
    monkeypatch.setattr(freeipa_community_portal.model.user, 'errors',
                        mock_errors)
    user = User()
    assert user.save() == 'test_valid'