diff --git a/tests/test_pagure_flask_ui_repo_slash_name.py b/tests/test_pagure_flask_ui_repo_slash_name.py index db7d264..3367fad 100644 --- a/tests/test_pagure_flask_ui_repo_slash_name.py +++ b/tests/test_pagure_flask_ui_repo_slash_name.py @@ -56,8 +56,45 @@ class PagureFlaskSlashInNametests(tests.Modeltests): tests.HERE, 'requests') self.app = pagure.APP.test_client() + def set_up_git_repo(self, name='test'): + """ Set up the git repo to play with. """ + + # Create a git repo to play with + gitrepo = os.path.join(tests.HERE, 'repos', '%s.git' % name) + repo = pygit2.init_repository(gitrepo, bare=True) + + newpath = tempfile.mkdtemp(prefix='pagure-other-test') + repopath = os.path.join(newpath, 'test') + clone_repo = pygit2.clone_repository(gitrepo, repopath) + + # Create a file in that git repo + with open(os.path.join(repopath, 'sources'), 'w') as stream: + stream.write('foo\n bar') + clone_repo.index.add('sources') + clone_repo.index.write() + + # Commits the files added + tree = clone_repo.index.write_tree() + author = pygit2.Signature( + 'Alice Author', 'alice@authors.tld') + committer = pygit2.Signature( + 'Cecil Committer', 'cecil@committers.tld') + clone_repo.create_commit( + 'refs/heads/master', # the name of the reference to update + author, + committer, + 'Add sources file for testing', + # binary string representing the tree object ID + tree, + # list of binary strings representing parents of the new commit + [] + ) + refname = 'refs/heads/master' + ori_remote = clone_repo.remotes[0] + PagureRepo.push(ori_remote, refname) + @patch('pagure.lib.notify.send_email') - def test_view_repo(self, send_email): + def test_view_repo_empty(self, send_email): """ Test the view_repo endpoint when the project has a slash in its name. """ @@ -116,6 +153,92 @@ class PagureFlaskSlashInNametests(tests.Modeltests): '