def test_create_article_with_slug(): art = Article( tweet_id=123, text="This is a tweet", title="This is a unique title", body="This is a detailed explanation of the news", url="http://clarin.com/url", html="algodehtml", created_at=datetime.utcnow() - timedelta(days=1), ) comments = [comment(), comment()] art.comments = comments art.save() art = Article.objects.get(tweet_id=123) assert art.slug is not None
def test_create_article(): art = Article( tweet_id=12345, text="This is a tweet", title="This is a title", body="This is a detailed explanation of the news", url="http://clarin.com/url", html="algodehtml", created_at=datetime.utcnow() - timedelta(days=1), ) comments = [comment(), comment()] art.comments = comments art.save() art = Article.objects.get(tweet_id=12345) assert len(art.comments) == 2 assert art.comments[0].text == comments[0].text assert art.comments[1].text == comments[1].text
def test_create_article_with_differents_slug(): art1 = Article( tweet_id=1919, text="This is a tweet", title="My title", body="This is a detailed explanation of the news", url="http://clarin.com/url", html="algodehtml", created_at=datetime.utcnow() - timedelta(days=1), ) art2 = Article( tweet_id=19191, text="This is a tweet", title="My title", url="http://clarin.com/url", html="algodehtml", body="This is a detailed explanation of the news", created_at=datetime.utcnow() - timedelta(days=1), ) art1.save() art2.save() assert art1.slug != art2.slug