diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py
index 694c1fc..f7824d3 100644
--- a/pagure/pfmarkdown.py
+++ b/pagure/pfmarkdown.py
@@ -267,7 +267,12 @@ def _pr_exists(user, namespace, repo, idx):
def _obj_anchor_tag(user, namespace, repo, obj, text):
- """ Utility method generating the link to an issue or a PR. """
+ """
+ Utility method generating the link to an issue or a PR.
+
+ :return: An element tree containing the href to the issue or PR
+ :rtype: xml.etree.ElementTree.Element
+ """
if obj.isa == 'issue':
url = flask.url_for(
'view_issue', username=user, namespace=namespace, repo=repo,
diff --git a/tests/test_pfmarkdown.py b/tests/test_pfmarkdown.py
new file mode 100644
index 0000000..de9329d
--- /dev/null
+++ b/tests/test_pfmarkdown.py
@@ -0,0 +1,55 @@
+import unittest
+from xml.etree import ElementTree
+
+from mock import patch, Mock
+
+from pagure import pfmarkdown
+from pagure.lib import model
+
+
+@patch('pagure.pfmarkdown.flask.url_for', Mock(return_value='http://eh/'))
+class TestObjAnchorTag(unittest.TestCase):
+ """
+ A set of tests for the pagure.pfmarkdown._obj_anchor_tag function
+ """
+
+ def test_obj_anchor_tag_issue(self):
+ """Assert links to issues are generated correctly"""
+ issue = model.Issue(
+ title='The issue summary',
+ content='The issue description',
+ )
+ expected_markup = (''
+ 'My Issue')
+ element = pfmarkdown._obj_anchor_tag(
+ 'jcline', None, None, issue, 'My Issue')
+
+ self.assertEqual(expected_markup, ElementTree.tostring(element))
+
+ def test_obj_anchor_tag_private_issue(self):
+ """Assert links to private issues hide the title"""
+ issue = model.Issue(
+ title='The private issue summary',
+ content='The issue description',
+ private=True
+ )
+ expected_markup = (''
+ 'My Issue')
+ element = pfmarkdown._obj_anchor_tag(
+ 'jcline', None, None, issue, 'My Issue')
+
+ self.assertEqual(expected_markup, ElementTree.tostring(element))
+
+ def test_obj_anchor_tag_pr(self):
+ """Assert links to pull requests are generated correctly"""
+ pr = model.PullRequest(title='The pull request summary')
+ expected_markup = ('My Pull Request')
+ element = pfmarkdown._obj_anchor_tag(
+ 'jcline', None, None, pr, 'My Pull Request')
+
+ self.assertEqual(expected_markup, ElementTree.tostring(element))
+
+
+if __name__ == '__main__':
+ unittest.main()