Mercurial > kallithea
changeset 5794:9d645f4ede35
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.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Sat, 09 Apr 2016 15:47:19 +0200 |
parents | fc8a5cbfa0da |
children | 078136fd83fb |
files | kallithea/tests/functional/test_files.py kallithea/tests/vcs/test_nodes.py |
diffstat | 2 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/tests/functional/test_files.py Thu Mar 31 20:53:23 2016 +0200 +++ b/kallithea/tests/functional/test_files.py Sat Apr 09 15:47:19 2016 +0200 @@ -1,6 +1,7 @@ # -*- 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 @@ 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()
--- a/kallithea/tests/vcs/test_nodes.py Thu Mar 31 20:53:23 2016 +0200 +++ b/kallithea/tests/vcs/test_nodes.py Sat Apr 09 15:47:19 2016 +0200 @@ -1,5 +1,6 @@ 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 @@ 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)