def test_show_articles_action(admin_client): topics = TopicFactory.create_batch(5) selected = choice(topics) ArticleFactory.create_batch(10) url = reverse("admin:lynx_topic_changelist") data = { "post": "yes", "_selected_action": [selected.pk], "action": "show_articles", } response = admin_client.post(url, data, follow=True) request = response.request slugs = selected.slug assert request["PATH_INFO"] == reverse("admin:lynx_article_changelist") assert request["QUERY_STRING"] == f"topics__slug__in={slugs}"
def test_merge_topics_action(admin_client): topics = TopicFactory.create_batch(5) article = ArticleFactory(topics=topics) selected = choice(topics) url = reverse("admin:lynx_topic_changelist") data = { "post": "yes", "_selected_action": [topic.pk for topic in topics], "action": "merge_topics", "selected": selected.pk, } admin_client.post(url, data, follow=True) # Merged topics are deleted actual = [topic.pk for topic in Topic.objects.all()] assert actual == [selected.pk] # Merged topics are replaced actual = [topic.pk for topic in article.topics.all()] assert actual == [selected.pk]
def articles(author): LabelFactory.create_batch(5) SourceFactory.create_batch(20) TopicFactory.create_batch(20) return ArticleFactory.create_batch(100, authors=[author])
def articles(): LabelFactory.create_batch(5) AuthorFactory.create_batch(10) TopicFactory.create_batch(20) NotificationFactory.create_batch(20) return ArticleFactory.create_batch(100)
def articles(source): LabelFactory.create_batch(5) AuthorFactory.create_batch(10) TopicFactory.create_batch(20) return ArticleFactory.create_batch(100, source=source)
def topics(): return TopicFactory.create_batch(100)
def articles(today): LabelFactory.create_batch(5) AuthorFactory.create_batch(10) TopicFactory.create_batch(10) SourceFactory.create_batch(10) return ArticleFactory.create_batch(10, date=today)