Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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")
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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")
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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