def test_save(self, target):
        from repoze.filesafe import _get_manager
        import os
        datamanager = _get_manager()
        mock_image = mock.Mock()
        mock_image.tostring.return_value = b"this-is-test-data"
        with TempDirectory() as d:
            store = target(d.path)
            store.save('testing', mock_image)
            mock_image.tostring.assert_called_with()

            assert os.path.join(d.path, 'testing') in datamanager.vault
    def test_load(self, target):
        from repoze.filesafe import _get_manager
        import os
        datamanager = _get_manager()
        with Replacer() as r, TempDirectory() as d:
            with datamanager.createFile(os.path.join(d.path, 'testing'), "w") as f:
                f.write(b'test-data')

            r.replace('rebecca.imagestore.stores.Image', DummyImage)

            store = target(d.path)
            result = store.load('testing')
            assert result.data == b'test-data'
示例#3
0
 def _callFUT(self, *a, **kw):
     from repoze.filesafe import _get_manager
     return _get_manager(*a, **kw)