def test_delete_invalid_value(self): yaml_data = textwrap.dedent(""" test: deleted: false """) with pytest.raises(ValueError, match='Invalid deleted value: False'): configdata._read_yaml(yaml_data)
def test_rename_unknown_target(self): yaml_data = textwrap.dedent(""" test: renamed: test2 """) with pytest.raises(ValueError, match='Renaming test to unknown test2'): configdata._read_yaml(yaml_data)
def test_invalid_keys(self): """Test reading with unknown keys.""" data = textwrap.dedent(""" test: type: Bool default: true desc: Hello World hello: world """,) with pytest.raises(ValueError, match='Invalid keys'): configdata._read_yaml(data)
def test_invalid_keys(self): """Test reading with unknown keys.""" data = textwrap.dedent(""" test: type: Bool default: true desc: Hello World hello: world """,) with pytest.raises(ValueError, match='Invalid keys'): configdata._read_yaml(data)
def test_delete(self): yaml_data = textwrap.dedent(""" test: deleted: true """) data, migrations = configdata._read_yaml(yaml_data) assert not data.keys() assert migrations.deleted == ['test']
def test_delete(self): yaml_data = textwrap.dedent(""" test: deleted: true """) data, migrations = configdata._read_yaml(yaml_data) assert not data.keys() assert migrations.deleted == ['test']
def test_shadowing(self, first, second, shadowing): """Make sure a setting can't shadow another.""" data = textwrap.dedent(""" {first}: type: Bool default: true desc: Hello World {second}: type: Bool default: true desc: Hello World """.format(first=first, second=second)) if shadowing: with pytest.raises(ValueError, match='Shadowing keys'): configdata._read_yaml(data) else: configdata._read_yaml(data)
def test_shadowing(self, first, second, shadowing): """Make sure a setting can't shadow another.""" data = textwrap.dedent(""" {first}: type: Bool default: true desc: Hello World {second}: type: Bool default: true desc: Hello World """.format(first=first, second=second)) if shadowing: with pytest.raises(ValueError, match='Shadowing keys'): configdata._read_yaml(data) else: configdata._read_yaml(data)
def test_rename(self): yaml_data = textwrap.dedent(""" test: renamed: test_new test_new: type: Bool default: true desc: Hello World """) data, migrations = configdata._read_yaml(yaml_data) assert data.keys() == {'test_new'} assert migrations.renamed == {'test': 'test_new'}
def test_rename(self): yaml_data = textwrap.dedent(""" test: renamed: test_new test_new: type: Bool default: true desc: Hello World """) data, migrations = configdata._read_yaml(yaml_data) assert data.keys() == {'test_new'} assert migrations.renamed == {'test': 'test_new'}
def test_valid(self): yaml_data = textwrap.dedent(""" test1: type: Bool default: true desc: Hello World test2: type: String default: foo backend: QtWebKit desc: Hello World 2 """) data, _migrations = configdata._read_yaml(yaml_data) assert data.keys() == {'test1', 'test2'} assert data['test1'].description == "Hello World" assert data['test2'].default == "foo" assert data['test2'].backends == [usertypes.Backend.QtWebKit] assert isinstance(data['test1'].typ, configtypes.Bool)
def test_valid(self): data = textwrap.dedent(""" test1: type: Bool default: true desc: Hello World test2: type: String default: foo backend: QtWebKit desc: Hello World 2 """) data = configdata._read_yaml(data) assert data.keys() == {'test1', 'test2'} assert data['test1'].description == "Hello World" assert data['test2'].default == "foo" assert data['test2'].backends == [usertypes.Backend.QtWebKit] assert isinstance(data['test1'].typ, configtypes.Bool)