예제 #1
0
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}"
예제 #2
0
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]
예제 #3
0
def articles(author):
    LabelFactory.create_batch(5)
    SourceFactory.create_batch(20)
    TopicFactory.create_batch(20)
    return ArticleFactory.create_batch(100, authors=[author])
예제 #4
0
def articles():
    LabelFactory.create_batch(5)
    AuthorFactory.create_batch(10)
    TopicFactory.create_batch(20)
    NotificationFactory.create_batch(20)
    return ArticleFactory.create_batch(100)
예제 #5
0
def articles(source):
    LabelFactory.create_batch(5)
    AuthorFactory.create_batch(10)
    TopicFactory.create_batch(20)
    return ArticleFactory.create_batch(100, source=source)
예제 #6
0
def topics():
    return TopicFactory.create_batch(100)
예제 #7
0
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)