예제 #1
0
def test_open_wrapper():
    """Test the wrapper around the return value of ``Node.open``.

    This should be remove in v2.0.0 because the wrapper should be removed.
    """
    filename = 'test'
    node = Node()
    node.put_object_from_filelike(io.StringIO('test'), filename)

    # Both `iter` and `next` should not raise
    next(node.open(filename))
    iter(node.open(filename))
    node.open(filename).__next__()
    node.open(filename).__iter__()
예제 #2
0
    def test_put_object_from_filelike(self):
        """Test the `put_object_from_filelike` method."""
        key = os.path.join('subdir', 'a.txt')
        filepath = os.path.join(self.tempdir, key)
        content = self.get_file_content(key)

        with io.open(filepath, 'r') as handle:
            node = Node()
            node.put_object_from_filelike(handle, key)
            self.assertEqual(node.get_object_content(key), content)

        key = os.path.join('subdir', 'nested', 'deep.txt')
        filepath = os.path.join(self.tempdir, key)
        content = self.get_file_content(key)

        with io.open(filepath, 'r') as handle:
            node = Node()
            node.put_object_from_filelike(handle, key)
            self.assertEqual(node.get_object_content(key), content)