Changeset - c6f5c3e60329
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-12-26 04:53:38
mads@kiilerich.com
Grafted from: eae4433628dd
tests: fix test_files.py json comparison to load json to struct so it is independent of serialization order

Py3 would fail the test because different ordering.
1 file changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_files.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
import json
 
import mimetypes
 
import posixpath
 

	
 
from kallithea.model.db import Repository
 
from kallithea.model.meta import Session
 
from kallithea.tests.base import *
 
@@ -116,22 +117,22 @@ class TestFilesController(TestController
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='history',
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
                                    f_path='vcs/nodes.py'),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
 
        assert response.body == HG_NODE_HISTORY
 
        assert json.loads(response.body) == json.loads(HG_NODE_HISTORY)
 

	
 
    def test_file_source_history_git(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='history',
 
                                    repo_name=GIT_REPO,
 
                                    revision='master',
 
                                    f_path='vcs/nodes.py'),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
 
        assert response.body == GIT_NODE_HISTORY
 
        assert json.loads(response.body) == json.loads(GIT_NODE_HISTORY)
 

	
 
    def test_file_annotation(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
@@ -155,24 +156,24 @@ class TestFilesController(TestController
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
                                    f_path='vcs/nodes.py',
 
                                    annotate='1'),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
 

	
 
        assert response.body == HG_NODE_HISTORY
 
        assert json.loads(response.body) == json.loads(HG_NODE_HISTORY)
 

	
 
    def test_file_annotation_history_git(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='history',
 
                                    repo_name=GIT_REPO,
 
                                    revision='master',
 
                                    f_path='vcs/nodes.py',
 
                                    annotate=True),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
 

	
 
        assert response.body == GIT_NODE_HISTORY
 
        assert json.loads(response.body) == json.loads(GIT_NODE_HISTORY)
 

	
 
    def test_file_authors(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='authors',
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
@@ -207,13 +208,13 @@ class TestFilesController(TestController
 
            heads = [
 
                ('Pragma', 'no-cache'),
 
                ('Cache-Control', 'no-cache'),
 
                ('Content-Disposition', 'attachment; filename=%s' % filename),
 
                ('Content-Type', info[0]),
 
            ]
 
            assert response.response._headers.items() == heads
 
            assert sorted(response.response._headers.items()) == sorted(heads)
 

	
 
    def test_archival_wrong_ext(self):
 
        self.log_user()
 
        _set_downloads(HG_REPO, set_to=True)
 
        for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']:
 
            fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext
0 comments (0 inline, 0 general)