From 35ffe0a9ff964086674ad36f2f3bf61c8cbe0ff1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 16 2018 17:02:37 +0000 Subject: Add test for running git blame file on a file at a tag Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 3cf785f..f600b52 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2468,6 +2468,39 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertIn( '
 barRow 0
', output.data) + def test_view_blame_file_on_tag(self): + """ Test the view_blame_file endpoint. """ + + regex = re.compile('>(\w+)\n') + tests.create_projects(self.session) + tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) + # Add some content to the git repo + tests.add_content_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + tests.add_readme_git_repo( + os.path.join(self.path, 'repos', 'test.git')) + + # add a tag to the git repo + repo = pygit2.Repository( + os.path.join(self.path, 'repos', 'test.git')) + commit = repo[repo.head.target] + tagger = pygit2.Signature('Alice Doe', 'adoe@example.com', 12347, 0) + repo.create_tag( + 'v1.0', commit.oid.hex, pygit2.GIT_OBJ_COMMIT, tagger, + "Release v1.0") + + # View for tag v1.0 + output = self.app.get('/test/blame/sources?identifier=v1.0') + self.assertEqual(output.status_code, 200) + self.assertIn(b'', output.data) + self.assertIn( + b'', output.data) + self.assertIn( + b'', output.data) + data = regex.findall(output.data) + self.assertEqual(len(data), 2) + def test_view_commit(self): """ Test the view_commit endpoint. """ output = self.app.get('/foo/c/bar')
 bar