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)
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)
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)
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')
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')
def test_custom_save_method_cannot_find_unregistered_brand(self): user_link = UserLinkFactory(url='http://blahblah.com/nlh-kabu') self.assertIsNone(user_link.icon)
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)
def test_string_method(self): user_link = UserLinkFactory(anchor='MyLink') self.assertEqual(user_link.__str__(), 'MyLink')