コード例 #1
0
    def test_listdir(self):
        self.assertEqual(self.storage.listdir(''), [[], []])

        self.filesystem.add_child('dir0', InMemoryDir())
        self.filesystem.add_child('file0', InMemoryFile())

        self.assertEqual(self.storage.listdir(''), [['dir0'], ['file0']])
        self.assertEqual(self.storage.listdir('dir0'), [[], []])

        self.filesystem.resolve('dir0').add_child('subdir', InMemoryDir())
        self.assertEqual(self.storage.listdir('dir0'), [['subdir'], []])
コード例 #2
0
    def test_delete(self):
        self.filesystem.add_child('dir0', InMemoryDir())
        self.filesystem.resolve('dir0').add_child('nested_file',
                                                  InMemoryFile())
        self.filesystem.add_child('file0', InMemoryFile())
        self.assertEqual(self.filesystem.resolve('dir0').ls(), ['nested_file'])

        self.storage.delete('dir0/nested_file')
        self.assertEqual(self.filesystem.resolve('dir0').ls(), [])
        self.assertEqual(set(self.filesystem.ls()), set(['dir0', 'file0']))

        self.storage.delete('dir0')
        self.assertEqual(set(self.filesystem.ls()), set(['file0']))
コード例 #3
0
def inmemorystorage(mocker):
    """
    Makes the InMemoryStorage backend persist its filesystem across multiple
    instantiations.
    """
    filesystem = InMemoryDir()

    MockedInMemoryStorage = functools.partial(
        InMemoryStorage,
        filesystem=filesystem,
        base_url='http://www.example.com/media/',
    )
    mocker.patch(
        'inmemorystorage.storage.InMemoryStorage',
        new=MockedInMemoryStorage,
    )

    return MockedInMemoryStorage()
コード例 #4
0
ファイル: test_utils.py プロジェクト: btbroot/exmo2010
 def tearDown(self):
     # Clear file storage between tests.
     default_storage.filesystem = InMemoryDir()