Example #1
0
    def setUpTestData(cls):
        cls.author_1 = create_author()
        cls.author_2 = create_author()

        cls.topics_by_author_1 = [
            create_topic(cls.author_1.id) for _ in range(2)
        ]
        cls.topics_by_author_2 = [
            create_topic(cls.author_2.id) for _ in range(2)
        ]

        cls.articles_by_author_1 = [
            create_article(author_id=cls.author_1.id,
                           topic_id=random.choice([
                               topic.pk for topic in cls.topics_by_author_2 +
                               cls.topics_by_author_1
                           ])) for _ in range(5)
        ]
        cls.articles_by_author_2 = [
            create_article(author_id=cls.author_2.id,
                           topic_id=random.choice([
                               topic.pk for topic in cls.topics_by_author_1 +
                               cls.topics_by_author_2
                           ])) for _ in range(5)
        ]
Example #2
0
    def setUpTestData(cls) -> None:
        cls.author = create_author()

        cls.topics = [create_topic(cls.author.pk) for _ in range(3)]

        cls.articles = [create_article(
            draft=False,
            author_id=cls.author.id,
            topic_id=random.choice(cls.topics).id,
        ) for _ in range(5)]

        create_article(
            topic_id=random.choice(cls.topics).id,
            author_id=cls.author.id,
            draft=True
        )
Example #3
0
 def setUpTestData(cls) -> None:
     cls.author = create_author()
     cls.topic = create_topic(cls.author.pk)
     cls.articles: List[Article] = [
         create_article(topic_id=cls.topic.id,
                        author_id=cls.author.id,
                        draft=False) for _ in range(5)
     ]
Example #4
0
    def setUpTestData(cls) -> None:

        # Create authors.
        cls.author: Author = create_author()

        # Create topics.
        cls.topics: typing.List[Topic] = list(reversed([
            create_topic(cls.author.id) for _ in range(25)
        ]))

        # For later testing.
        cls.topic_1: Topic = random.choice(cls.topics)
        cls.topic_2: Topic = random.choice(cls.topics)

        kwargs = {'draft': False, 'author_id': cls.author.id}

        cls.articles_for_topic_1 = [create_article(topic_id=cls.topic_1.id, **kwargs) for _ in range(5)]
        cls.articles_for_topic_2 = [create_article(topic_id=cls.topic_2.id, **kwargs) for _ in range(5)]