Пример #1
0
    def test_false_positive_does_not_apply_brand(self):
        UserLinkFactory(url='http://notreallyfacebook.com/me')

        BrandFactory(name='Facebook', domain='facebook.com',
                     fa_icon='fa-facebook')

        # Retreive the link to check that it does not have the new brand
        link = UserLink.objects.get(url='http://notreallyfacebook.com/me')

        self.assertIsNone(link.icon)
Пример #2
0
    def test_custom_save_method_applies_new_brand_to_existing_userlinks(self):
        UserLinkFactory(url='http://facebook.com/myusername')

        new_brand = BrandFactory(name='Facebook',
                                 domain='facebook.com',
                                 fa_icon='fa-facebook')

        # Retreive the link to check that it has the new brand
        link = UserLink.objects.get(url='http://facebook.com/myusername')

        self.assertEqual(link.icon, new_brand)
Пример #3
0
    def test_can_match_link_to_brand(self):
        github = BrandFactory()
        link_user = UserFactory()
        link = UserLinkFactory(
            user=link_user,
            anchor='Github',
            url='http://github.com/myaccount/',
        )
        userlinks = [link]

        match_link_to_brand(userlinks)
        link = UserLink.objects.get(user=link_user)

        self.assertEqual(link.icon, github)
Пример #4
0
    def test_get_icon_method_gets_default_icon(self):
        user_link = UserLinkFactory(url='http://noiconurl.com')
        icon = user_link.get_icon()

        self.assertEqual(icon, 'fa-globe')
Пример #5
0
    def test_get_icon_method_gets_correct_icon(self):
        user_link = UserLinkFactory(url='http://github.com/nlh-kabu')
        icon = user_link.get_icon()

        self.assertEqual(icon, 'fa-github')
Пример #6
0
    def test_custom_save_method_cannot_find_unregistered_brand(self):
        user_link = UserLinkFactory(url='http://blahblah.com/nlh-kabu')

        self.assertIsNone(user_link.icon)
Пример #7
0
    def test_custom_save_method_finds_registered_brand(self):
        user_link = UserLinkFactory(url='http://github.com/nlh-kabu')

        self.assertEqual(user_link.icon, self.github)
Пример #8
0
    def test_string_method(self):
        user_link = UserLinkFactory(anchor='MyLink')

        self.assertEqual(user_link.__str__(), 'MyLink')