def test_init_existing(self): """Verify an existing file is read.""" with patch('yorm.common.read_text', Mock(return_value="abc: 123")): sample = utilities.sync(self.Sample(), "sample.yml") assert 123 == sample.abc
def test_with_attrs(self): """Verify mapping can be enabled with with attributes.""" attrs = {'var1': MockConverter} sample = utilities.sync(self.Sample(), "sample.yml", attrs) assert "sample.yml" == sample.yorm_mapper.path assert {'var1': MockConverter} == sample.yorm_mapper.attrs
def test_multiple(self): """Verify mapping cannot be enabled twice.""" sample = utilities.sync(self.Sample(), "sample.yml") with pytest.raises(common.UseageError): utilities.sync(sample, "sample.yml")
def test_no_attrs(self): """Verify mapping can be enabled with no attributes.""" sample = utilities.sync(self.Sample(), "sample.yml") assert "sample.yml" == sample.yorm_mapper.path assert {} == sample.yorm_mapper.attrs