コード例 #1
0
ファイル: test_mapper.py プロジェクト: fenildf/yorm
def mapper(tmpdir, obj, attrs, request):
    path = request.param + "/path/to/file"
    backup = yorm.settings.fake
    if "fake" in path:
        yorm.settings.fake = True
    elif "real" in path:
        tmpdir.chdir()
    yield Mapper(obj, path, attrs, auto_track=False)
    yorm.settings.fake = backup
コード例 #2
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
コード例 #3
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
コード例 #4
0
ファイル: test_mapper.py プロジェクト: fenildf/yorm
def mapper_fake(obj, attrs):
    backup = yorm.settings.fake
    yorm.settings.fake = True
    yield Mapper(obj, "fake/path/to/file", attrs)
    yorm.settings.fake = backup
コード例 #5
0
ファイル: test_mapper.py プロジェクト: fenildf/yorm
def mapper_real(tmpdir, obj, attrs):
    tmpdir.chdir()
    return Mapper(obj, "real/path/to/file", attrs)