コード例 #1
0
    def test_file_permission_on_new_file_have_correct_value(
            self, store, perms, value):
        src = BytesIO(value)

        key = store.put_file(u'test123', src)

        parts = urlparse(store.url_for(key))
        path = parts.path

        mode = os.stat(path).st_mode
        mask = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

        assert mode & mask == perms
コード例 #2
0
    def test_file_permission_on_new_file_have_correct_value(
        self, store, perms, value
    ):
        src = BytesIO(value)

        key = store.put_file('test123', src)

        parts = urlparse(store.url_for(key))
        path = parts.path

        mode = os.stat(path).st_mode
        mask = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

        assert mode & mask == perms
コード例 #3
0
    def test_file_uri(self, store, value):
        tmpfile = tempfile.NamedTemporaryFile(delete=False)
        try:
            tmpfile.write(value)
            tmpfile.close()

            key = store.put_file(u'testkey', tmpfile.name)
            url = store.url_for(key)

            assert url.startswith('file://')
            parts = urlparse(url)

            ndata = open(parts.path, 'rb').read()
            assert value == ndata
        finally:
            if os.path.exists(tmpfile.name):
                os.unlink(tmpfile.name)
コード例 #4
0
    def test_file_uri(self, store, value):
        tmpfile = tempfile.NamedTemporaryFile(delete=False)
        try:
            tmpfile.write(value)
            tmpfile.close()

            key = store.put_file('testkey', tmpfile.name)
            url = store.url_for(key)

            assert url.startswith('file://')
            parts = urlparse(url)

            ndata = open(parts.path, 'rb').read()
            assert value == ndata
        finally:
            if os.path.exists(tmpfile.name):
                os.unlink(tmpfile.name)
コード例 #5
0
    def test_file_permissions_on_moved_in_file_have_correct_value(
            self, store, perms, key, value):
        tmpfile = tempfile.NamedTemporaryFile(delete=False)
        tmpfile.write(value)
        tmpfile.close()
        os.chmod(tmpfile.name, 0o777)
        try:
            key = store.put_file(key, tmpfile.name)

            parts = urlparse(store.url_for(key))
            path = url_unquote(parts.path)

            mode = os.stat(path).st_mode
            mask = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

            assert mode & mask == perms
        finally:
            if os.path.exists(tmpfile.name):
                os.path.unlink(tmpfile.name)
コード例 #6
0
    def test_file_permissions_on_moved_in_file_have_correct_value(
        self, store, perms, key, value
    ):
        tmpfile = tempfile.NamedTemporaryFile(delete=False)
        tmpfile.write(value)
        tmpfile.close()
        os.chmod(tmpfile.name, 0o777)
        try:
            key = store.put_file(key, tmpfile.name)

            parts = urlparse(store.url_for(key))
            path = url_unquote(parts.path)

            mode = os.stat(path).st_mode
            mask = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

            assert mode & mask == perms
        finally:
            if os.path.exists(tmpfile.name):
                os.path.unlink(tmpfile.name)