def test_article_can_count_links_in_its_body(self): a = G(Article, raw_content='this article has two links http://devcharm.com and https://127.0.0.1:8000') self.assertEqual(a.count_own_links(), 2) # This should work for 0 links too a.raw_content = 'No links here' self.assertEqual(a.count_own_links(), 0) # And we should also be able to use the static method directly: self.assertEqual(Article.count_links('this article has one link http://devcharm.com'), 1) # Duplicate links should not be counted twice self.assertEqual(Article.count_links('this article has one link http://devcharm.com http://devcharm.com'), 1)
def test_article_can_count_links_in_its_body(self): a = G( Article, raw_content= 'this article has two links http://devcharm.com and https://127.0.0.1:8000' ) self.assertEqual(a.count_own_links(), 2) # This should work for 0 links too a.raw_content = 'No links here' self.assertEqual(a.count_own_links(), 0) # And we should also be able to use the static method directly: self.assertEqual( Article.count_links( 'this article has one link http://devcharm.com'), 1) # Duplicate links should not be counted twice self.assertEqual( Article.count_links( 'this article has one link http://devcharm.com http://devcharm.com' ), 1)