From c43375de7e109ee3d724739ec87f2dfd0d9b514c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 23 2017 10:43:43 +0000 Subject: Add tests for the UI of commit flags Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_flask_ui_repo_flag_commit.py b/tests/test_pagure_flask_ui_repo_flag_commit.py new file mode 100644 index 0000000..47d4ef6 --- /dev/null +++ b/tests/test_pagure_flask_ui_repo_flag_commit.py @@ -0,0 +1,270 @@ +# -*- coding: utf-8 -*- + +""" + (c) 2017 - Copyright Red Hat Inc + + Authors: + Pierre-Yves Chibon + +""" + +import unittest +import sys +import os + +import pygit2 + +sys.path.insert(0, os.path.join(os.path.dirname( + os.path.abspath(__file__)), '..')) + +import pagure +import pagure.lib +import tests + + +class ViewCommitFlagtests(tests.SimplePagureTest): + """ Tests for the UI related to commit flags """ + + def setUp(self): + """ Set up the environnment, ran before every tests. """ + super(ViewCommitFlagtests, self).setUp() + + pagure.APP.config['TESTING'] = True + pagure.SESSION = self.session + pagure.ui.SESSION = self.session + pagure.ui.app.SESSION = self.session + pagure.ui.filters.SESSION = self.session + pagure.ui.repo.SESSION = self.session + + tests.create_projects(self.session) + tests.create_tokens(self.session) + + # Add a README to the git repo - First commit + tests.add_readme_git_repo(os.path.join(self.path, 'repos', 'test.git')) + repo = pygit2.Repository(os.path.join(self.path, 'repos', 'test.git')) + self.commit = repo.revparse_single('HEAD') + + def test_view_commit_no_flag(self): + """ Test the view_commit endpoint. """ + + # View first commit + output = self.app.get('/test/c/%s' % self.commit.oid.hex) + self.assertEqual(output.status_code, 200) + self.assertIn( + 'Commit - test - %s - Pagure' % self.commit.oid.hex, + output.data) + self.assertIn( + '