Blame tests/test_pagure_flask_ui_slash_branch_name.py

Pierre-Yves Chibon 016a1b
# -*- coding: utf-8 -*-
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
"""
Pierre-Yves Chibon 016a1b
 (c) 2015 - Copyright Red Hat Inc
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
 Authors:
Pierre-Yves Chibon 016a1b
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
"""
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 67d1cc
from __future__ import unicode_literals, absolute_import
Aurélien Bompard dcf6f6
Pierre-Yves Chibon 016a1b
import json
Pierre-Yves Chibon 016a1b
import unittest
Pierre-Yves Chibon 016a1b
import shutil
Pierre-Yves Chibon 016a1b
import sys
Pierre-Yves Chibon 016a1b
import tempfile
Pierre-Yves Chibon 016a1b
import os
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
import pygit2
Pierre-Yves Chibon 016a1b
from mock import patch
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
sys.path.insert(
Pierre-Yves Chibon 73d120
    0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
Pierre-Yves Chibon 73d120
)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 930073
import pagure.lib.query
Pierre-Yves Chibon 016a1b
import tests
Pierre-Yves Chibon 27a73d
from pagure.lib.repo import PagureRepo
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
Clement Verna 109c4b
class PagureFlaskSlashInBranchtests(tests.SimplePagureTest):
Pierre-Yves Chibon 016a1b
    """ Tests for flask application when the branch name contains a '/'.
Pierre-Yves Chibon 016a1b
    """
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
    def set_up_git_repo(self):
Pierre-Yves Chibon 016a1b
        """ Set up the git repo to play with. """
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # Create a git repo to play with
Pierre-Yves Chibon 73d120
        gitrepo = os.path.join(self.path, "repos", "test.git")
Pierre-Yves Chibon 016a1b
        repo = pygit2.init_repository(gitrepo, bare=True)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
        newpath = tempfile.mkdtemp(prefix="pagure-other-test")
Pierre-Yves Chibon 73d120
        repopath = os.path.join(newpath, "test")
Pierre-Yves Chibon 016a1b
        clone_repo = pygit2.clone_repository(gitrepo, repopath)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # Create a file in that git repo
Pierre-Yves Chibon 73d120
        with open(os.path.join(repopath, "sources"), "w") as stream:
Pierre-Yves Chibon 73d120
            stream.write("foo\n bar")
Pierre-Yves Chibon 73d120
        clone_repo.index.add("sources")
Pierre-Yves Chibon 016a1b
        clone_repo.index.write()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # Commits the files added
Pierre-Yves Chibon 016a1b
        tree = clone_repo.index.write_tree()
Pierre-Yves Chibon 73d120
        author = pygit2.Signature("Alice Author", "alice@authors.tld")
Pierre-Yves Chibon 73d120
        committer = pygit2.Signature("Cecil Committer", "cecil@committers.tld")
Pierre-Yves Chibon 016a1b
        clone_repo.create_commit(
Pierre-Yves Chibon 73d120
            "refs/heads/master",  # the name of the reference to update
Pierre-Yves Chibon 016a1b
            author,
Pierre-Yves Chibon 016a1b
            committer,
Pierre-Yves Chibon 73d120
            "Add sources file for testing",
Pierre-Yves Chibon 016a1b
            # binary string representing the tree object ID
Pierre-Yves Chibon 016a1b
            tree,
Pierre-Yves Chibon 016a1b
            # list of binary strings representing parents of the new commit
Pierre-Yves Chibon 73d120
            [],
Pierre-Yves Chibon 016a1b
        )
Pierre-Yves Chibon 73d120
        refname = "refs/heads/master"
Pierre-Yves Chibon 016a1b
        ori_remote = clone_repo.remotes[0]
Pierre-Yves Chibon 27a73d
        PagureRepo.push(ori_remote, refname)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
        master_branch = clone_repo.lookup_branch("master")
Pierre-Yves Chibon 29ff0a
        first_commit = master_branch.peel().hex
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # Second commit
Pierre-Yves Chibon 73d120
        with open(os.path.join(repopath, ".gitignore"), "w") as stream:
Pierre-Yves Chibon 73d120
            stream.write("*~")
Pierre-Yves Chibon 73d120
        clone_repo.index.add(".gitignore")
Pierre-Yves Chibon 016a1b
        clone_repo.index.write()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        tree = clone_repo.index.write_tree()
Pierre-Yves Chibon 73d120
        author = pygit2.Signature("Alice Author", "alice@authors.tld")
Pierre-Yves Chibon 73d120
        committer = pygit2.Signature("Cecil Committer", "cecil@committers.tld")
Pierre-Yves Chibon 016a1b
        clone_repo.create_commit(
Pierre-Yves Chibon 73d120
            "refs/heads/maxamilion/feature",
Pierre-Yves Chibon 016a1b
            author,
Pierre-Yves Chibon 016a1b
            committer,
Pierre-Yves Chibon 73d120
            "Add .gitignore file for testing",
Pierre-Yves Chibon 016a1b
            # binary string representing the tree object ID
Pierre-Yves Chibon 016a1b
            tree,
Pierre-Yves Chibon 016a1b
            # list of binary strings representing parents of the new commit
Pierre-Yves Chibon 73d120
            [first_commit],
Pierre-Yves Chibon 016a1b
        )
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
        refname = "refs/heads/maxamilion/feature"
Pierre-Yves Chibon 016a1b
        ori_remote = clone_repo.remotes[0]
Pierre-Yves Chibon 27a73d
        PagureRepo.push(ori_remote, refname)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        shutil.rmtree(newpath)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
    @patch("pagure.lib.notify.send_email")
Pierre-Yves Chibon 016a1b
    def test_view_repo(self, send_email):
Pierre-Yves Chibon 016a1b
        """ Test the view_repo endpoint when the git repo has no master
Pierre-Yves Chibon 016a1b
        branch.
Pierre-Yves Chibon 016a1b
        """
Pierre-Yves Chibon 016a1b
        send_email.return_value = True
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        tests.create_projects(self.session)
Pierre-Yves Chibon 016a1b
        # Non-existant git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        self.set_up_git_repo()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # With git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 77bdcd
        output_text = output.get_data(as_text=True)
Pierre-Yves Chibon 19b2ae
        self.assertIn(
Pierre-Yves Chibon 77bdcd
            '
Pierre-Yves Chibon 95e961
            'value="git://localhost.localdomain/test.git" readonly>',
Pierre-Yves Chibon 73d120
            output_text,
Pierre-Yves Chibon 73d120
        )
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 77bdcd
    '''
Pierre-Yves Chibon 016a1b
    @patch('pagure.lib.notify.send_email')
Pierre-Yves Chibon 016a1b
    def test_view_repo_branch(self, send_email):
Pierre-Yves Chibon 016a1b
        """ Test the view_repo_branch endpoint when the git repo has no
Pierre-Yves Chibon 016a1b
        master branch.
Pierre-Yves Chibon 016a1b
        """
Pierre-Yves Chibon 016a1b
        send_email.return_value = True
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        tests.create_projects(self.session)
Pierre-Yves Chibon 016a1b
        # Non-existant git repo
Pierre-Yves Chibon 016a1b
        output = self.app.get('/test/branch/master')
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        self.set_up_git_repo()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # With git repo
Pierre-Yves Chibon 016a1b
        output = self.app.get('/test/branch/maxamilion/feature')
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 200)
Aurélien Bompard 626417
        output_text = output.get_data(as_text=True)
Pierre-Yves Chibon 19b2ae
        self.assertIn(
Pierre-Yves Chibon 77bdcd
            '
Pierre-Yves Chibon 95e961
            'value="git://localhost.localdomain/test.git" readonly>', output_text)
Pierre-Yves Chibon 77bdcd
    '''
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
    @patch("pagure.lib.notify.send_email")
Pierre-Yves Chibon 016a1b
    def test_view_commits(self, send_email):
Pierre-Yves Chibon 016a1b
        """ Test the view_commits endpoint when the git repo has no
Pierre-Yves Chibon 016a1b
        master branch.
Pierre-Yves Chibon 016a1b
        """
Pierre-Yves Chibon 016a1b
        send_email.return_value = True
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        tests.create_projects(self.session)
Pierre-Yves Chibon 016a1b
        # Non-existant git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test/commits")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        self.set_up_git_repo()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # With git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test/commits")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 73d120
        self.assertEqual(
Pierre-Yves Chibon 73d120
            output.get_data(as_text=True).count('
Pierre-Yves Chibon 73d120
        )
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
        output = self.app.get("/test/commits/maxamilion/feature")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 200)
Aurélien Bompard 626417
        output_text = output.get_data(as_text=True)
Pierre-Yves Chibon 73d120
        self.assertIn("<title>Commits - test - Pagure</title>", output_text)
Pierre-Yves Chibon 73d120
        self.assertIn("Add sources file for testing", output_text)
Pierre-Yves Chibon 73d120
        self.assertIn("Add .gitignore file for testing", output_text)
Aurélien Bompard 626417
        self.assertEqual(output_text.count('
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 73d120
    @patch("pagure.lib.notify.send_email")
Pierre-Yves Chibon 016a1b
    def test_view_file(self, send_email):
Pierre-Yves Chibon 016a1b
        """ Test the view_file endpoint when the git repo has no
Pierre-Yves Chibon 016a1b
        master branch.
Pierre-Yves Chibon 016a1b
        """
Pierre-Yves Chibon 016a1b
        send_email.return_value = True
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        tests.create_projects(self.session)
Pierre-Yves Chibon 016a1b
        # Non-existant git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test/blob/master/f/sources")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        self.set_up_git_repo()
Pierre-Yves Chibon 016a1b
Pierre-Yves Chibon 016a1b
        # With git repo
Pierre-Yves Chibon 73d120
        output = self.app.get("/test/blob/master/f/sources")
Pierre-Yves Chibon 016a1b
        self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 016a1b
        self.assertIn(
Pierre-Yves Chibon 73d120
            """
    Pierre-Yves Chibon 77bdcd
              
  1. Pierre-Yves Chibon 557220
                
    Pierre-Yves Chibon 77bdcd
                  
    Pierre-Yves Chibon 557220
                    master
    Pierre-Yves Chibon 557220
                
    Pierre-Yves Chibon 557220
              
    Pierre-Yves Chibon 77bdcd
              
  2. Pierre-Yves Chibon 77bdcd
                
    Pierre-Yves Chibon 557220
                  sources
    Pierre-Yves Chibon 557220
              
    Pierre-Yves Chibon 73d120
            """,
    Pierre-Yves Chibon 73d120
                output.get_data(as_text=True),
    Pierre-Yves Chibon 73d120
            )
    Pierre-Yves Chibon 016a1b
    Pierre-Yves Chibon 73d120
            output = self.app.get("/test/blob/master/f/.gitignore")
    Pierre-Yves Chibon 016a1b
            self.assertEqual(output.status_code, 404)
    Pierre-Yves Chibon 016a1b
    Pierre-Yves Chibon 73d120
            output = self.app.get("/test/blob/maxamilion/feature/f/.gitignore")
    Pierre-Yves Chibon 016a1b
            self.assertEqual(output.status_code, 200)
    Aurélien Bompard 626417
            output_text = output.get_data(as_text=True)
    Pierre-Yves Chibon 016a1b
            self.assertIn(
    Pierre-Yves Chibon 73d120
                """
      Pierre-Yves Chibon 77bdcd
                
    1. Pierre-Yves Chibon 557220
                  
      Pierre-Yves Chibon 77bdcd
                    
      Pierre-Yves Chibon 557220
                      maxamilion/feature
      Pierre-Yves Chibon 557220
                  
      Pierre-Yves Chibon 557220
                
      Pierre-Yves Chibon 77bdcd
                
    2. Pierre-Yves Chibon 77bdcd
                  
      Pierre-Yves Chibon 557220
                    .gitignore
      Pierre-Yves Chibon 557220
                
      Pierre-Yves Chibon 73d120
              """,
      Pierre-Yves Chibon 73d120
                  output_text,
      Pierre-Yves Chibon 73d120
              )
      Pierre-Yves Chibon 967e77
              self.assertIn(
      Ryan Lerch 9fe1c6
                  '
      '
      Ryan Lerch 9fe1c6
                  '*~',
      Pierre-Yves Chibon 73d120
                  output_text,
      Pierre-Yves Chibon 2d9829
              )
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
          @patch("pagure.lib.notify.send_email")
      Pierre-Yves Chibon 016a1b
          def test_view_raw_file(self, send_email):
      Pierre-Yves Chibon 016a1b
              """ Test the view_raw_file endpoint when the git repo has no
      Pierre-Yves Chibon 016a1b
              master branch.
      Pierre-Yves Chibon 016a1b
              """
      Pierre-Yves Chibon 016a1b
              send_email.return_value = True
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              tests.create_projects(self.session)
      Pierre-Yves Chibon 016a1b
              # Non-existant git repo
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/master")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/master/f/sources")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              self.set_up_git_repo()
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              # With git repo
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/master")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Pierre-Yves Chibon 73d120
              self.assertIn("diff --git a/sources b/sources", output_text)
      Pierre-Yves Chibon 73d120
              self.assertIn("+foo\n+ bar", output_text)
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/master/f/sources")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Pierre-Yves Chibon 73d120
              self.assertEqual(output.get_data(as_text=True), "foo\n bar")
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/maxamilion/feature")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Pierre-Yves Chibon 73d120
              self.assertIn("diff --git a/.gitignore b/.gitignore", output_text)
      Pierre-Yves Chibon 73d120
              self.assertIn("+*~", output_text)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/raw/maxamilion/feature/f/sources")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Pierre-Yves Chibon 73d120
              self.assertEqual("foo\n bar", output.get_data(as_text=True))
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
          @patch("pagure.lib.notify.send_email")
      Pierre-Yves Chibon 016a1b
          def test_view_tree(self, send_email):
      Pierre-Yves Chibon 016a1b
              """ Test the view_tree endpoint when the git repo has no
      Pierre-Yves Chibon 016a1b
              master branch.
      Pierre-Yves Chibon 016a1b
              """
      Pierre-Yves Chibon 016a1b
              send_email.return_value = True
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              tests.create_projects(self.session)
      Pierre-Yves Chibon 016a1b
              # Non-existant git repo
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/master")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              self.set_up_git_repo()
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              # With git repo
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/master")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Aurélien Bompard 626417
              self.assertIn('', output_text)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/master/sources")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Aurélien Bompard 626417
              self.assertIn('', output_text)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/feature")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Aurélien Bompard 626417
              self.assertIn('', output_text)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/maxamilion/feature")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Pierre-Yves Chibon 016a1b
              self.assertIn(
      Pierre-Yves Chibon 73d120
                  '', output_text
      Pierre-Yves Chibon 73d120
              )
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              # Wrong identifier, back onto master
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/tree/maxamilion/feature/f/.gitignore")
      Pierre-Yves Chibon 016a1b
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Aurélien Bompard 626417
              self.assertIn('', output_text)
      Ryan Lerch 0cb181
      Pierre-Yves Chibon 73d120
          @patch("pagure.lib.notify.send_email")
      Pierre-Yves Chibon 016a1b
          def test_new_request_pull(self, send_email):
      Pierre-Yves Chibon 016a1b
              """ Test the new_request_pull endpoint when the git repo has no
      Pierre-Yves Chibon 016a1b
              master branch.
      Pierre-Yves Chibon 016a1b
              """
      Pierre-Yves Chibon 016a1b
              send_email.return_value = True
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              tests.create_projects(self.session)
      Pierre-Yves Chibon 016a1b
              # Non-existant git repo
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/diff/master..maxamilion/feature")
      Pierre-Yves Chibon 4fcf92
              # (used to be 302 but seeing a diff is allowed even logged out)
      Pierre-Yves Chibon 4fcf92
              self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              user = tests.FakeUser()
      Pierre-Yves Chibon b130e5
              with tests.user_set(self.app.application, user):
      Pierre-Yves Chibon 73d120
                  output = self.app.get("/test/diff/master..maxamilion/feature")
      Pierre-Yves Chibon 016a1b
                  self.assertEqual(output.status_code, 404)
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              self.set_up_git_repo()
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
              output = self.app.get("/test/diff/master..maxamilion/feature")
      Pierre-Yves Chibon 4fcf92
              # (used to be 302 but seeing a diff is allowed even logged out)
      Pierre-Yves Chibon 4fcf92
              self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
              output_text = output.get_data(as_text=True)
      Pierre-Yves Chibon 73d120
              self.assertEqual(output_text.count('
      Pierre-Yves Chibon 15a1bc
              self.assertIn(
      Ryan Lerch 92c2a8
                  ''
      Pierre-Yves Chibon 73d120
                  "+1\n",
      Pierre-Yves Chibon 73d120
                  output_text,
      Pierre-Yves Chibon 73d120
              )
      Pierre-Yves Chibon 15a1bc
              self.assertIn(
      Ryan Lerch 92c2a8
                  '
      \n'
      Pierre-Yves Chibon 73d120
                  "    file added\n",
      Pierre-Yves Chibon 73d120
                  output_text,
      Pierre-Yves Chibon 73d120
              )
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
              user = tests.FakeUser()
      Pierre-Yves Chibon b130e5
              with tests.user_set(self.app.application, user):
      Pierre-Yves Chibon 73d120
                  output = self.app.get("/test/diff/master..maxamilion/feature")
      Pierre-Yves Chibon 016a1b
                  self.assertEqual(output.status_code, 200)
      Aurélien Bompard 626417
                  output_text = output.get_data(as_text=True)
      Pierre-Yves Chibon 73d120
                  self.assertEqual(output_text.count('
      Pierre-Yves Chibon 15a1bc
                  self.assertIn(
      Ryan Lerch 92c2a8
                      ''
      Pierre-Yves Chibon 73d120
                      "+1\n",
      Pierre-Yves Chibon 73d120
                      output_text,
      Pierre-Yves Chibon 73d120
                  )
      Pierre-Yves Chibon 15a1bc
                  self.assertIn(
      Ryan Lerch 92c2a8
                      '
      \n'
      Pierre-Yves Chibon 73d120
                      "    file added\n",
      Pierre-Yves Chibon 73d120
                      output_text,
      Pierre-Yves Chibon 73d120
                  )
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 016a1b
      Pierre-Yves Chibon 73d120
      if __name__ == "__main__":
      Pierre-Yves Chibon 393f31
          unittest.main(verbosity=2)