示例#1
0
def test_update():
    """ tests that field's are updated correctly """

    state = State(read=read, create=create, update=update)
    state.update(["read", "test0"], read=False, update=True, isdatafile=True)

    for field in state.fields:
        if field.name not in ["read", "test0"]:
            if field.name in update:
                assert field.update
            if field.name in read:
                assert field.read
            if field.name in create:
                assert field.create
            assert not field.isdatafile
        else:
            assert not field.read
            assert field.update
            assert field.isdatafile
示例#2
0
    def test_update(self):
        """
        tests that field's are updated correctly
        """
        _state = State(read=read, save=save, update=update)
        _state.update(['read', 'test0'],
                      read=False, update=True, isdatafile=True)

        for field in _state.fields:
            if field.name not in ['read', 'test0']:
                if field.name in update:
                    assert field.update
                if field.name in read:
                    assert field.read
                if field.name in save:
                    assert field.save
                assert not field.isdatafile
            else:
                assert not field.read
                assert field.update
                assert field.isdatafile
示例#3
0
    def test_update_exceptions(self):
        """
        test exceptions are raised if update and read are both True
        for a field
        """
        _state = State(read=read, save=save, update=update)
        with pytest.raises(AttributeError):
            _state.update(['read', 'test0'], update=True)

        with pytest.raises(AttributeError):
            _state.update(['read', 'test0'], read=True, update=True)

        with pytest.raises(AttributeError):
            _state.update(['read', 'test0'], read=True)
示例#4
0
def test_update_exceptions():
    """
    test exceptions are raised if update and read are both True
    for a field
    """

    state = State(read=read, create=create, update=update)
    with pytest.raises(AttributeError):
        state.update(["read", "test0"], update=True)

    with pytest.raises(AttributeError):
        state.update(["read", "test0"], read=True, update=True)

    with pytest.raises(AttributeError):
        state.update(["read", "test0"], read=True)