Ejemplo n.º 1
0
    def setUp(self):
        """ Set up the environnment, ran before every tests. """
        super(PagureFlaskRepoViewFileForktests, self).setUp()

        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'))
        tests.add_binary_git_repo(os.path.join(self.path, 'repos', 'test.git'),
                                  'test.jpg')
        tests.add_binary_git_repo(os.path.join(self.path, 'repos', 'test.git'),
                                  'test_binary')

        # Add a fork of a fork
        item = pagure.lib.model.Project(
            user_id=1,  # pingou
            name='test',
            description='test project #3',
            is_fork=True,
            parent_id=1,
            hook_token='aaabbbppp',
        )
        self.session.add(item)
        self.session.commit()

        tests.add_content_git_repo(
            os.path.join(self.path, 'repos', 'forks', 'pingou', 'test.git'))
        tests.add_readme_git_repo(
            os.path.join(self.path, 'repos', 'forks', 'pingou', 'test.git'))
        tests.add_commit_git_repo(os.path.join(self.path, 'repos', 'forks',
                                               'pingou', 'test.git'),
                                  ncommits=10)
Ejemplo n.º 2
0
 def test_view_history_file_binary(self):
     """ Test the view_history_file endpoint """
     # Add binary content
     tests.add_binary_git_repo(os.path.join(self.path, "repos", "test.git"),
                               "test.jpg")
     output = self.app.get("/test/history/test.jpg")
     self.assertEqual(output.status_code, 200)
     output_text = output.get_data(as_text=True)
     self.assertIn("<strong>Add a fake image file</strong>", output_text)
Ejemplo n.º 3
0
 def test_view_blame_file_binary(self):
     """ Test the view_blame_file endpoint """
     # Add binary content
     tests.add_binary_git_repo(os.path.join(self.path, "repos", "test.git"),
                               "test.jpg")
     output = self.app.get("/test/blame/test.jpg")
     self.assertEqual(output.status_code, 400)
     output_text = output.get_data(as_text=True)
     self.assertIn("<title>400 Bad Request</title>", output_text)
     self.assertIn("<p>Binary files cannot be blamed</p>", output_text)
Ejemplo n.º 4
0
    def setUp(self):
        """ Set up the environnment, ran before every tests. """
        super(PagureFlaskRepoViewFiletests, self).setUp()
        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'))
        tests.add_binary_git_repo(os.path.join(self.path, 'repos', 'test.git'),
                                  'test.jpg')
        tests.add_binary_git_repo(os.path.join(self.path, 'repos', 'test.git'),
                                  'test_binary')