Esempio n. 1
0
def handle():
    randomize.out("\ntags:")
    for i in range(50):
        Tag(name=randomize.string(20)).save()
        randomize.out('.')
    print "\nusers:",
    for i in range(5):
        user, created = User.objects.get_or_create(
            username='******' % i,
            email='*****@*****.**' % str(i),
            password='******',
            is_blog_author=True,
            first_name=u'Иван%s' % str(i),
            second_name=u'Иванович%s' % str(i),
            last_name=u'Иванов%s' % str(i),
        )

        if created:
            user.save()

        print "\nposts"
        for j in range(50):
            post = Post(
                author=user,
                title='Post%s' % str(i),
                text='Post text %s' % str(i),
                published=True,
                enable_comments=True,
            )
            post.save()
            if randomize.boolean():
                post.tags = Tag.objects.order_by('?')[:randomize.integer(1, 6)]
            randomize.out('.')
        randomize.out('.')
Esempio n. 2
0
    def setUpClass(cls):
        super().setUpClass()
        session = cls.Session()
        cls.username = '******'
        cls.password = '******'
        user = User(username=cls.username,
                    password=str(
                        bcrypt.hashpw(cls.password.encode('utf-8'),
                                      bcrypt.gensalt()), 'utf-8'),
                    avatar='Katarina.png',
                    introduction='L')
        article = Article(
            user=user,
            title='L',
            introduction='L',
            markdown_content='L',
            compiled_content='L',
        )
        tag = Tag(content='hello')
        article.tag.append(tag)
        user.tag.append(tag)
        session.add(user)
        session.add(article)

        fish_record = Record(
            title='hello',
            content=['hello'],
            image_num=1,
            source='hello',
        )
        session.add(fish_record)
        session.commit()
        session.close()
Esempio n. 3
0
 def mutate_and_get_payload(cls, input, info):
     try:
         tag = Tag()
         tag.name = input.get('name')
         tag.full_clean()
         tag.save()
         return CreateTag(tag=tag)
     except ValidationError as e:
         return CreateTag(tag=None, errors=getErrors(e))
Esempio n. 4
0
 def setUp(self) -> None:
     super().setUp()
     self.tag = Tag(name='new tag')
     self.tag.save()
     self.post = Post(title='admin',
                      body='*****@*****.**',
                      author=self.current_user)
     self.post.save()
     self.post.tags.add(self.tag)
     self.post.save()
Esempio n. 5
0
 def setUp(self) -> None:
     super(TagAPITests, self).setUp()
     self.tag = Tag(name='new tag')
     self.tag.save()