コード例 #1
0
    def test_img_url(self):
        url = get_img_path(self.parent_comment_1)
        self.assertNotEqual(url, '')
        # use default pic on fail
        settings.PROFILE_APP_NAME = 'app not exist'
        url = get_img_path(self.parent_comment_1)
        self.assertEqual(url, '/static/img/default.png')

        settings.PROFILE_APP_NAME = None
        url = get_img_path(self.parent_comment_1)
        self.assertEqual(url, '/static/img/default.png')
コード例 #2
0
ファイル: test_template_tags.py プロジェクト: taehyu/Comment
    def test_img_url(self):
        url = get_img_path(self.parent_comment_1)
        self.assertNotEqual(url, '')
        # fail
        settings.PROFILE_APP_NAME = 'app not exist'
        url = get_img_path(self.parent_comment_1)
        self.assertEqual(url, '')

        settings.PROFILE_APP_NAME = None
        url = get_img_path(self.parent_comment_1)
        self.assertEqual(url, '')
コード例 #3
0
    def test_get_img_path(self):
        url = get_img_path(self.parent_comment_1)
        self.assertNotEqual(url, '/static/img/default.png')

        # use default pic on fail
        with patch.object(settings, 'PROFILE_MODEL_NAME', 'app not exist'):
            url = get_img_path(self.parent_comment_1)
            self.assertEqual(url, '/static/img/default.png')

        with patch.object(settings, 'PROFILE_APP_NAME', 'user_profile'):
            with patch('comment.templatetags.comment_tags.get_profile_instance', return_value=None):
                url = get_img_path(self.parent_comment_1)
                self.assertEqual(url, '/static/img/default.png')
コード例 #4
0
ファイル: test_template_tags.py プロジェクト: taehyu/Comment
 def test_profile_has_no_image_field(self):
     mocked_hasattr = patch(
         'comment.templatetags.comment_tags.hasattr').start()
     mocked_hasattr.return_value = False
     url = get_img_path(self.parent_comment_1)
     self.assertEqual(url, '')
コード例 #5
0
 def test_profile_has_no_image_field(self):
     with patch('comment.templatetags.comment_tags.hasattr',
                return_value=False):
         url = get_img_path(self.parent_comment_1)
         self.assertEqual(url, '/static/img/default.png')
コード例 #6
0
 def test_profile_with_image(self):
     with patch('comment.templatetags.comment_tags.get_profile_instance',
                return_value=None):
         url = get_img_path(self.parent_comment_1)
         self.assertEqual(url, '/static/img/default.png')
コード例 #7
0
 def test_profile_is_not_found(self):
     url = get_img_path(self.parent_comment_1)
     self.assertEqual(url, settings.COMMENT_DEFAULT_PROFILE_PIC_LOC)
コード例 #8
0
 def test_get_img_path(self):
     url = get_img_path(self.parent_comment_1)
     self.assertNotEqual(url, '/static/img/default.png')