def setUp(self): self.client = Client() self.category = CategoryFactory() self.test_author1 = AuthorFactory(name='xyz', slug="xyz") self.test_article_author1 = ArticleAuthors(author=self.test_author1, sort_order=0) self.test_article_author1b = ArticleAuthors(author=self.test_author1, sort_order=0) self.test_author2 = AuthorFactory(name='abc', slug="abc") self.test_article_author2 = ArticleAuthors(author=self.test_author2, sort_order=1) self.test_article_author2b = ArticleAuthors(author=self.test_author2, sort_order=1) self.english_article = ArticleFactory( title="english_article", authors=(self.test_article_author1, ), language='en', first_published_at='2011-10-24 12:43') self.hindi_article = ArticleFactory( title="hindi_article", authors=(self.test_article_author1b, self.test_article_author2), language='hi', first_published_at='2011-10-25 12:43') self.dummy_article = ArticleFactory( title="dummy_article", authors=(self.test_article_author2b, ), language='en', first_published_at='2011-10-23 12:43')
def setUp(self): self.client = Client() self.test_author = AuthorFactory(name='xyz', slug="xyz") self.test_article_author = ArticleAuthors(author=self.test_author, sort_order=0) self.article = ArticleFactory(title="english_article", authors=(self.test_article_author, ), language='en')
def setUp(self): self.client = Client() self.author = AuthorFactory(name='test', slug="test") self.article_author = ArticleAuthors(author=self.author, sort_order=0) self.article = ArticleFactory(title="test article", authors=(self.article_author, ), language='en') self.article = ArticleFactory(title="test modular article", show_modular_content=True)
def setUpClass(cls): super(TestHomePage, cls).setUpClass() author1 = AuthorFactory.create() article_author1 = ArticleAuthors(author=author1, sort_order=0) author2 = AuthorFactory.create(name="Karthik", slug="srk") article_author2 = ArticleAuthors(author=author2, sort_order=0) category1 = CategoryFactory.create(name="Resource Conflicts", slug="resource-conflicts", order=1, description="Jal, jungle, zameen") category2 = CategoryFactory.create(name="Adivasis", slug="adivasis", order=2, description="The first dwellers") category3 = CategoryFactory.create(name="Dalits", slug="dalits", order=3, description="Struggles of the oppressed") category4 = CategoryFactory.create(name="Rural Sports", slug="sports-games", order=4, description="Games people play") location1 = LocationFactory.create() location2 = LocationFactory.create(name="Madurai", slug="madurai") image = ImageFactory.create(photographers=(author1,), locations=(location1,)) setup = DataSetup() article1 = setup.create_article("article1", article_author1, category1, location1, image) article2 = setup.create_article("article2", article_author2, category2, location2, image) video_article = setup.create_video_article("video article", article_author2, location1, image) talking_album = setup.create_talking_album(image) photo_album = setup.create_photo_album(image) HomePageFactory.create(carousel_0=article1, carousel_1=article2, in_focus_page1=article1, in_focus_page2=article2, video=video_article, talking_album=talking_album, photo_album=photo_album)
def test_articles_are_only_12_in_a_page_for_the_author_xyz(self): # Creating 14 articles for name in range(1, 15): ArticleFactory(title="article" + str(name), authors=(ArticleAuthors(author=self.test_author1, sort_order=name - 1), )) response_for_page_one = self.client.get('/authors/xyz/?lang=all') response_for_page_two = self.client.get( '/authors/xyz/?page=2&lang=all') self.assertEqual(len(response_for_page_one.context_data['articles']), 12) self.assertEqual(len(response_for_page_two.context_data['articles']), 4)
def setUpClass(cls): super(TestArticlePage, cls).setUpClass() author = AuthorFactory.create(name="Nimesh", slug="puli") article_author = ArticleAuthors(author=author, sort_order=0) category = CategoryFactory.create(name="Adivasis", slug="adivasis", order=2, description="The first dwellers") location = LocationFactory.create(name="Madurai", slug="madurai") image = ImageFactory.create(photographers=(author, ), locations=(location, )) setup = DataSetup() dummy_article = setup.create_article("Dummy", article_author, category, location, image) modular_article = setup.create_article("Article Page", article_author, category, location, image, show_modular_content=True, modular_content=json.dumps( get_modular_content( dummy_article.id, image.id, location.id)))
def test_multiple_authors_can_be_added_to_a_article(self): author= AuthorFactory(name='Test') article_author = ArticleAuthors(author=author, sort_order=1) article = ArticleFactory(title="Multiple Author Article", authors=(self.test_article_author,article_author,)) self.assertEqual(len(article.authors.all()),2) self.assertEqual(article.authors.all()[1].author.name,'Test')