From a484630cf4f69a2d53d88d15f4c55ec812eea7c3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 19 2016 13:25:14 +0000 Subject: [PATCH 1/3] Adjust the tests to allow specifying the filename of the file to change --- diff --git a/tests/__init__.py b/tests/__init__.py index 13e8132..3cf0597 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -431,7 +431,7 @@ Dev instance: http://209.132.184.222/ (/!\\ May change unexpectedly, it's a dev shutil.rmtree(newfolder) -def add_commit_git_repo(folder, ncommits=10): +def add_commit_git_repo(folder, ncommits=10, filename='sources'): """ Create some more commits for the specified git repo. """ if not os.path.exists(folder): os.makedirs(folder) @@ -442,9 +442,9 @@ def add_commit_git_repo(folder, ncommits=10): for index in range(ncommits): # Create a file in that git repo - with open(os.path.join(newfolder, 'sources'), 'a') as stream: + with open(os.path.join(newfolder, filename), 'a') as stream: stream.write('Row %s\n' % index) - repo.index.add('sources') + repo.index.add(filename) repo.index.write() parents = [] @@ -466,7 +466,7 @@ def add_commit_git_repo(folder, ncommits=10): 'refs/heads/master', # the name of the reference to update author, committer, - 'Add row %s to sources file' % index, + 'Add row %s to %s file' % (index, filename), # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit From f487a0538abcdc65a5fdfeff2b5e443674ca771d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 19 2016 13:25:14 +0000 Subject: [PATCH 2/3] Adjust the compare_commit tests with a file having a non-ascii name --- diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index d674d59..d3caded 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1261,7 +1261,8 @@ class PagureFlaskRepotests(tests.Modeltests): # Add one more commit to git repo tests.add_commit_git_repo( - os.path.join(tests.HERE, 'test.git'), ncommits=1) + os.path.join(tests.HERE, 'test.git'), + ncommits=1, filename='Šource') c3 = repo.revparse_single('HEAD') compare_first_two(c1, c2) From 3c6ab69973438bec09f8b611dd758ef143a90bb6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 19 2016 13:25:14 +0000 Subject: [PATCH 3/3] Fix viewing a diff of different commits with a file having a non-ascii name --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 5686c2e..77c1247 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -99,7 +99,7 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, 'cnt': '%s_%s' % (index, cnt), 'cnt_lbl': cnt, 'img': flask.url_for('static', filename='users.png'), - 'filename': filename, + 'filename': filename.decode('UTF-8'), 'commit': commit, 'tree_id': tree_id, } diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index d3caded..119279b 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -1191,7 +1191,7 @@ class PagureFlaskRepotests(tests.Modeltests): output.data) self.assertIn( '' + - '@@ -1,1 +1,3 @@', + '@@ -1,1 +1,2 @@', output.data) self.assertIn( '+ Row 0', output.data) @@ -1204,6 +1204,11 @@ class PagureFlaskRepotests(tests.Modeltests): 'class="label label-default label-pill hidden-sm-down">' + '\n 3\n ', output.data) + self.assertIn( + 'title="View file as of 4829cf">Šource', output.data) + self.assertIn( + '
file added
', output.data) + # View inverse commits comparison output = self.app.get( '/test/c/%s..%s' % (c3.oid.hex, c1.oid.hex)) @@ -1217,20 +1222,24 @@ class PagureFlaskRepotests(tests.Modeltests): output.data) self.assertIn( '' + - '@@ -1,3 +1,1 @@', + '@@ -1,2 +1,1 @@', output.data) self.assertIn( '- Row 0', output.data) self.assertEqual( output.data.count( - '- Row 0'), 2) + '- Row 0'), 1) self.assertIn( 'Commits \n ' + '' + '\n 3\n ', output.data) + self.assertIn( + 'title="View file as of 000000">Šource', output.data) + self.assertIn( + '
file removed
', output.data) output = self.app.get('/foo/bar') # No project registered in the DB