view MoinMoin/util/_tests/test_send_file.py @ 1364:582e7109a8c1

mass update - delete trailing spaces and/or add blank line to end of file
author Roger Haase <crosseyedpenguin@yahoo.com>
date Wed, 06 Jun 2012 15:03:07 -0700
parents 4cd6611b0cf8
children 440b2150593d
line wrap: on
line source
# -*- coding: utf-8 -*-
# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
MoinMoin - MoinMoin.util.send_file Tests
"""

import os
import tempfile, shutil

from MoinMoin.util import send_file
import pytest

class TestFuid(object):
    """ test for send_file """

    def setup_method(self, method):
        self.test_dir = tempfile.mkdtemp('', 'test_dir')
        self.fname = os.path.join(self.test_dir, "test_file")

    def teardown_method(self, method):
        shutil.rmtree(self.test_dir)

    def makefile(self, fname, content):
        f = open(fname, "w")
        f.write(content)
        f.close()

    def test_temptest(self):
        self.makefile(self.fname, 'test_content')
        result = send_file.send_file(self.fname, as_attachment = True, conditional = True)
        expected = '<Response streamed [200 OK]>'
        assert str(result) == expected

        with pytest.raises(TypeError):
            send_file.send_file(None, as_attachment = True)