Пример #1
0
    def test_save_and_insert(self):
        author = Author(name='test author 6')
        author.save()

        post = Post(title='test title 6', content='test content 6', pub_date=datetime.now(), author_id='6')
        post.save()

        c = db.execute('select * from author where id=6;')
        self.assertEqual(len(c.fetchall()), 1)
        c = db.execute('select * from my_post where id=6;')
        self.assertEqual(len(c.fetchall()), 1)
Пример #2
0
    def test_save_and_insert(self):
        author = Author(name='test author 6')
        author.save()

        post = Post(title='test title 6',
                    content='test content 6',
                    pub_date=datetime.now(),
                    author_id='6')
        post.save()

        c = db.execute('select * from author where id=6;')
        self.assertEqual(len(c.fetchall()), 1)
        c = db.execute('select * from my_post where id=6;')
        self.assertEqual(len(c.fetchall()), 1)
Пример #3
0
    def setUp(self):
        db.create_table(Author)
        db.create_table(Post)
        db.create_table(Tag)

        for i in range(1, 6):
            db.execute('insert into {tablename}({columns}) values({items});'.format(
                tablename='author',
                columns='name',
                items='"test author {0}"'.format(str(i))
            ))
            db.execute('insert into {tablename}({columns}) values({items});'.format(
                tablename='my_post',
                columns='title, content, author_id',
                items='"test title {0}", "test content {0}", {0}'.format(str(i))
            ))
            db.execute('insert into {tablename}({columns}) values({items});'.format(
                tablename='tag',
                columns='name',
                items='"test tag {0}"'.format(str(i))
            ))
        db.commit()
Пример #4
0
    def setUp(self):
        db.create_table(Author)
        db.create_table(Post)
        db.create_table(Tag)

        for i in range(1, 6):
            db.execute(
                'insert into {tablename}({columns}) values({items});'.format(
                    tablename='author',
                    columns='name',
                    items='"test author {0}"'.format(str(i))))
            db.execute(
                'insert into {tablename}({columns}) values({items});'.format(
                    tablename='my_post',
                    columns='title, content, author_id',
                    items='"test title {0}", "test content {0}", {0}'.format(
                        str(i))))
            db.execute(
                'insert into {tablename}({columns}) values({items});'.format(
                    tablename='tag',
                    columns='name',
                    items='"test tag {0}"'.format(str(i))))
        db.commit()