test_pagure_flask_ui_plugins_default_hook.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2016 - Copyright Red Hat Inc
  4. Authors:
  5. Pierre-Yves Chibon <pingou@pingoured.fr>
  6. """
  7. from __future__ import unicode_literals, absolute_import
  8. import json
  9. import unittest
  10. import shutil
  11. import sys
  12. import os
  13. import flask
  14. import pygit2
  15. from mock import patch, MagicMock
  16. sys.path.insert(0, os.path.join(os.path.dirname(
  17. os.path.abspath(__file__)), '..'))
  18. import pagure.hooks.default
  19. import pagure.lib.plugins
  20. import pagure.lib.query
  21. import tests
  22. class PagureFlaskPluginDefaultHooktests(tests.Modeltests):
  23. """ Tests for default_hook plugin of pagure """
  24. def test_plugin_default_active_on_project(self):
  25. """ Test that the default hook is active on random project. """
  26. tests.create_projects(self.session)
  27. test = pagure.lib.query.search_projects(self.session)[0]
  28. self.assertIsNone(pagure.hooks.default.Default.backref)
  29. self.assertTrue(
  30. pagure.hooks.default.Default.is_enabled_for(test)
  31. )
  32. self.assertEqual(
  33. [(pagure.hooks.default.Default, None)],
  34. pagure.lib.plugins.get_enabled_plugins(test)
  35. )
  36. if __name__ == '__main__':
  37. unittest.main(verbosity=2)