Blame tests/test_pfmarkdown.py

Jeremy Cline e1630c
import unittest
Jeremy Cline e1630c
from xml.etree import ElementTree
Jeremy Cline e1630c
Jeremy Cline e1630c
from mock import patch, Mock
Jeremy Cline e1630c
Jeremy Cline e1630c
from pagure import pfmarkdown
Jeremy Cline e1630c
from pagure.lib import model
Jeremy Cline e1630c
Jeremy Cline e1630c
Jeremy Cline e1630c
@patch('pagure.pfmarkdown.flask.url_for', Mock(return_value='http://eh/'))
Jeremy Cline e1630c
class TestObjAnchorTag(unittest.TestCase):
Jeremy Cline e1630c
    """
Jeremy Cline e1630c
    A set of tests for the pagure.pfmarkdown._obj_anchor_tag function
Jeremy Cline e1630c
    """
Jeremy Cline e1630c
Jeremy Cline e1630c
    def test_obj_anchor_tag_issue(self):
Jeremy Cline e1630c
        """Assert links to issues are generated correctly"""
Jeremy Cline e1630c
        issue = model.Issue(
Jeremy Cline e1630c
            title='The issue summary',
Jeremy Cline e1630c
            content='The issue description',
Jeremy Cline e1630c
        )
Jeremy Cline e1630c
        expected_markup = (''
Jeremy Cline e1630c
                           'My Issue')
Jeremy Cline e1630c
        element = pfmarkdown._obj_anchor_tag(
Jeremy Cline e1630c
            'jcline', None, None, issue, 'My Issue')
Jeremy Cline e1630c
Jeremy Cline e1630c
        self.assertEqual(expected_markup, ElementTree.tostring(element))
Jeremy Cline e1630c
Jeremy Cline e1630c
    def test_obj_anchor_tag_private_issue(self):
Jeremy Cline e1630c
        """Assert links to private issues hide the title"""
Jeremy Cline e1630c
        issue = model.Issue(
Jeremy Cline e1630c
            title='The private issue summary',
Jeremy Cline e1630c
            content='The issue description',
Jeremy Cline e1630c
            private=True
Jeremy Cline e1630c
        )
Jeremy Cline e1630c
        expected_markup = (''
Jeremy Cline e1630c
                           'My Issue')
Jeremy Cline e1630c
        element = pfmarkdown._obj_anchor_tag(
Jeremy Cline e1630c
            'jcline', None, None, issue, 'My Issue')
Jeremy Cline e1630c
Jeremy Cline e1630c
        self.assertEqual(expected_markup, ElementTree.tostring(element))
Jeremy Cline e1630c
Jeremy Cline e1630c
    def test_obj_anchor_tag_pr(self):
Jeremy Cline e1630c
        """Assert links to pull requests are generated correctly"""
Jeremy Cline e1630c
        pr = model.PullRequest(title='The pull request summary')
Jeremy Cline e1630c
        expected_markup = ('
Jeremy Cline e1630c
                           'summary">My Pull Request')
Jeremy Cline e1630c
        element = pfmarkdown._obj_anchor_tag(
Jeremy Cline e1630c
            'jcline', None, None, pr, 'My Pull Request')
Jeremy Cline e1630c
Jeremy Cline e1630c
        self.assertEqual(expected_markup, ElementTree.tostring(element))
Jeremy Cline e1630c
Jeremy Cline e1630c
Jeremy Cline e1630c
if __name__ == '__main__':
Pierre-Yves Chibon 393f31
    unittest.main(verbosity=2)