|
@@ -25,6 +25,7 @@ from django.test import TestCase
|
|
|
# Third-party Python library imports.
|
|
|
import palette
|
|
|
import pydot
|
|
|
import mock
|
|
|
|
|
|
# Application imports.
|
|
|
from conntrackt.models import Entity, Project, Communication
|
|
@@ -287,3 +288,40 @@ class GenerateProjectDiagramTest(TestCas
|
|
|
self.assertEqual("transparent", diagram.get_bgcolor())
|
|
|
self.assertEqual("1.5", diagram.get_nodesep())
|
|
|
self.assertEqual([{"shape": "record"}], diagram.get_node_defaults())
|
|
|
|
|
|
|
|
|
class ListFormatterCallbackTest(TestCase):
|
|
|
"""
|
|
|
Tests the list_formatter_callback function.
|
|
|
"""
|
|
|
|
|
|
def test_get_absolute_url(self):
|
|
|
"""
|
|
|
Test the return result in case the get_absolute_url is available on
|
|
|
passed object instance.
|
|
|
"""
|
|
|
|
|
|
# Set-up a minimal object mock.
|
|
|
obj = mock.Mock(spec=["_meta", "__repr__", "get_absolute_url"])
|
|
|
obj._meta = mock.Mock()
|
|
|
obj._meta.verbose_name = "name"
|
|
|
obj.__repr__ = mock.Mock()
|
|
|
obj.__repr__.return_value = "representation"
|
|
|
obj.get_absolute_url.return_value = "url"
|
|
|
|
|
|
self.assertEqual(utils.list_formatter_callback(obj), '<strong>Name</strong>: <a href="url">representation</a>')
|
|
|
|
|
|
def test_no_get_absolute_url(self):
|
|
|
"""
|
|
|
Test the return result in case the get_absolute_url is not available on
|
|
|
passed object instance.
|
|
|
"""
|
|
|
|
|
|
# Set-up a minimal object mock.
|
|
|
obj = mock.Mock(spec=["_meta", "__repr__"])
|
|
|
obj._meta = mock.Mock()
|
|
|
obj._meta.verbose_name = "name"
|
|
|
obj.__repr__ = mock.Mock()
|
|
|
obj.__repr__.return_value = "representation"
|
|
|
|
|
|
self.assertEqual(utils.list_formatter_callback(obj), "<strong>Name</strong>: representation")
|