Changeset - 9d645f4ede35
[Not reviewed]
default
0 2 0
domruf - 10 years ago 2016-04-09 15:47:19
dominikruf@gmail.com
tests: fix test_nodes.py and test_files.py which fail on windows due to mimetype differences

The mimetype of files may differ on different platforms (e.g. the mimetype of
.py files on windows is not text/x-python but text/plain). Therefore, compare
the mimetype to the value the platform uses.
2 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_files.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
import os
 
import posixpath
 
import mimetypes
 
from kallithea.tests import *
 
from kallithea.model.db import Repository
 
from kallithea.model.meta import Session
 
@@ -242,7 +243,7 @@ removed extra unicode conversion in diff
 
                                    f_path='vcs/nodes.py'))
 

	
 
        self.assertEqual(response.content_disposition, "attachment; filename=nodes.py")
 
        self.assertEqual(response.content_type, "text/x-python")
 
        self.assertEqual(response.content_type, mimetypes.guess_type("nodes.py")[0])
 

	
 
    def test_raw_file_wrong_cs(self):
 
        self.log_user()
kallithea/tests/vcs/test_nodes.py
Show inline comments
 

	
 
import stat
 
import mimetypes
 
from kallithea.lib.vcs.nodes import DirNode
 
from kallithea.lib.vcs.nodes import FileNode
 
from kallithea.lib.vcs.nodes import Node
 
@@ -159,11 +160,11 @@ class NodeBasicTest(unittest.TestCase):
 
        my_node3 = FileNode('myfile3')
 
        my_node3._mimetype = [ext,ext]
 

	
 
        self.assertEqual(py_node.mimetype,'text/x-python')
 
        self.assertEqual(py_node.get_mimetype(),('text/x-python',None))
 
        self.assertEqual(py_node.mimetype, mimetypes.guess_type(py_node.name)[0])
 
        self.assertEqual(py_node.get_mimetype(), mimetypes.guess_type(py_node.name))
 

	
 
        self.assertEqual(tar_node.mimetype,'application/x-tar')
 
        self.assertEqual(tar_node.get_mimetype(),('application/x-tar','gzip'))
 
        self.assertEqual(tar_node.mimetype, mimetypes.guess_type(tar_node.name)[0])
 
        self.assertEqual(tar_node.get_mimetype(), mimetypes.guess_type(tar_node.name))
 

	
 
        self.assertRaises(NodeError,my_node2.get_mimetype)
 

	
0 comments (0 inline, 0 general)