예제 #1
0
 def test_get_context_object_name_from_attr(self):
     """
     Test :py:meth:`.SingleObjectMixin.get_context_object_name` from attr.
     """
     mixin = SingleObjectMixin()
     mixin.context_object_name = 'foo'
     self.assertEqual('foo', mixin.get_context_object_name())
예제 #2
0
 def test_get_context_object_name_from_attr(self):
     """
     Test :py:meth:`.SingleObjectMixin.get_context_object_name` from attr.
     """
     mixin = SingleObjectMixin()
     mixin.context_object_name = 'foo'
     self.assertEqual('foo', mixin.get_context_object_name())
예제 #3
0
 def test_get_context_data(self):
     """
     Test :py:meth:`.SingleObjectMixin.get_context_data`.
     """
     mixin = SingleObjectMixin()
     mixin.object = Mock()
     mixin.get_context_object_name = Mock(return_value='obj_name')
     self.assertEqual({
         'foo': 'bar',
         'obj_name': mixin.object,
     }, mixin.get_context_data(foo='bar'))
예제 #4
0
 def test_get_context_data(self):
     """
     Test :py:meth:`.SingleObjectMixin.get_context_data`.
     """
     mixin = SingleObjectMixin()
     mixin.object = Mock()
     mixin.get_context_object_name = Mock(return_value='obj_name')
     self.assertEqual({
         'foo': 'bar',
         'obj_name': mixin.object,
     }, mixin.get_context_data(foo='bar'))
예제 #5
0
    def test_get_context_object_name_from_obj(self):
        """
        Test :py:meth:`.SingleObjectMixin.get_context_object_name` from obj.
        """
        class Foo(object):
            pass

        class Bar(object):
            pass

        for class_obj, expected in [
                    (Foo, 'foo'),
                    (Bar, 'bar'),
                ]:
            mixin = SingleObjectMixin()
            mixin.document_class = class_obj
            self.assertEqual(expected, mixin.get_context_object_name())
예제 #6
0
    def test_get_context_object_name_from_obj(self):
        """
        Test :py:meth:`.SingleObjectMixin.get_context_object_name` from obj.
        """
        class Foo(object):
            pass

        class Bar(object):
            pass

        for class_obj, expected in [
            (Foo, 'foo'),
            (Bar, 'bar'),
        ]:
            mixin = SingleObjectMixin()
            mixin.document_class = class_obj
            self.assertEqual(expected, mixin.get_context_object_name())