Пример #1
0
    def test_missing_attributes_added(self):
        obj = self.MyObject()
        path = "mock/path"
        attrs = {'bar': Integer, 'qux': Integer}
        mapper = Mapper(obj, path, attrs)
        mapper.create()
        mapper.fetch()

        assert 1 == obj.foo
        assert 0 == obj.bar
        assert 0 == obj.qux
Пример #2
0
    def test_auto_off(self, tmpdir):
        """Verify storage is delayed with auto off."""
        tmpdir.chdir()
        obj = self.MyObject()
        attrs = {'number': Integer}
        mapper = Mapper(obj, "real/path/to/file", attrs, auto=False)
        assert False is mapper.auto

        mapper.create()
        assert "" == mapper.text
        assert False is mapper.auto

        mapper.store()
        assert "" == mapper.text
        assert False is mapper.auto

        mapper.store(force=True)
        assert "number: 0\n" == mapper.text
        assert False is mapper.auto