示例#1
0
def test_bool_of_empty_entry():
    """Test that the bool value of an empty entry is False"""
    entry = config.ConfigurationEntry("empty", "")
    assert not entry
示例#2
0
def test_repr_of_entry():
    """Test that the repr of an entry is sensible"""
    entry = config.ConfigurationEntry("key", "value")
    assert repr(entry) == "ConfigurationEntry(key='key', value='value')"
示例#3
0
def test_bool_of_entry():
    """Test the bool value of an entry"""
    entry = config.ConfigurationEntry("key", "value")
    assert entry
示例#4
0
def test_enum_is_used():
    """Test that entry is marked as used when accessed as enum"""
    entry = config.ConfigurationEntry("test", "info")
    assert entry.is_used is False
    entry.as_enum("log_level")
    assert entry.is_used is True
示例#5
0
def test_access_enum():
    """Test getting the value of an entry as an enum (has no property access)"""
    entry = config.ConfigurationEntry("test", "info")
    assert entry.as_enum("log_level") is enums.get_value("log_level", "info")
示例#6
0
def test_entry_is_used(test_case):
    """Test that entry is marked as used when accessing value"""
    entry = config.ConfigurationEntry("test", test_case.cfg_value)
    assert entry.is_used is False
    getattr(entry, test_case.type)
    assert entry.is_used is True
示例#7
0
def test_access_entry(test_case):
    """Test getting values of entries through accessors"""
    entry = config.ConfigurationEntry("test", test_case.cfg_value)
    assert getattr(entry, test_case.type) == test_case.value
    assert getattr(entry, f"as_{test_case.type}")() == test_case.value