Blame tests/test_pagure_flask_ui_plugins_default_hook.py
|
Pierre-Yves Chibon |
317b75 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
"""
|
|
Pierre-Yves Chibon |
317b75 |
(c) 2016 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
Authors:
|
|
Pierre-Yves Chibon |
317b75 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
"""
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
dcf6f6 |
|
|
Pierre-Yves Chibon |
317b75 |
import json
|
|
Pierre-Yves Chibon |
317b75 |
import unittest
|
|
Pierre-Yves Chibon |
317b75 |
import shutil
|
|
Pierre-Yves Chibon |
317b75 |
import sys
|
|
Pierre-Yves Chibon |
317b75 |
import os
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
1d97e0 |
import flask
|
|
Pierre-Yves Chibon |
317b75 |
import pygit2
|
|
Pierre-Yves Chibon |
1d97e0 |
from mock import patch, MagicMock
|
|
Pierre-Yves Chibon |
317b75 |
|
|
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 |
317b75 |
|
|
Slavek Kabrda |
adbb5f |
import pagure.hooks.default
|
|
Slavek Kabrda |
adbb5f |
import pagure.lib.plugins
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
Pierre-Yves Chibon |
317b75 |
import tests
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
class PagureFlaskPluginDefaultHooktests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
317b75 |
""" Tests for default_hook plugin of pagure """
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Slavek Kabrda |
adbb5f |
def test_plugin_default_active_on_project(self):
|
|
Slavek Kabrda |
adbb5f |
""" Test that the default hook is active on random project. """
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
tests.create_projects(self.session)
|
|
Slavek Kabrda |
adbb5f |
test = pagure.lib.query.search_projects(self.session)[0]
|
|
Slavek Kabrda |
adbb5f |
self.assertIsNone(pagure.hooks.default.Default.backref)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertTrue(pagure.hooks.default.Default.is_enabled_for(test))
|
|
Slavek Kabrda |
adbb5f |
self.assertEqual(
|
|
Slavek Kabrda |
adbb5f |
[(pagure.hooks.default.Default, None)],
|
|
Pierre-Yves Chibon |
73d120 |
pagure.lib.plugins.get_enabled_plugins(test),
|
|
Pierre-Yves Chibon |
1d97e0 |
)
|
|
Pierre-Yves Chibon |
1d97e0 |
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
73d120 |
if __name__ == "__main__":
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|