Exemplo n.º 1
0
Arquivo: test.py Projeto: GrupoIS2/CMS
    def testarticlecreatepost(self):
        user = User(
            username='******',
            email='*****@*****.**',
            password='******',
            role=1,
            status=1
            )
        db.session.add(user)
        db.session.commit()
        testsection = Sections(
            section_='sectionname',
            description_='section created to test an article')
        db.session.add(testsection)
        db.session.commit()
        usertest = User.query.filter(User.username == 'Testuser').first()
        testarticle = Article(
            title='testtitle',
            body='testbody',
            section_name=testsection.section_name,
            section=testsection,
            user_name=usertest.username,
            user=usertest,
        )
        db.session.add(testarticle)
        db.session.commit()

        self.assertTrue(testarticle.find_by_id(testarticle.id) is not None)
        self.assertTrue(
            testarticle.find_by_author(testarticle.user_name) is not None)
        self.assertTrue(
            testarticle.find_by_section('testsection')is not None)
Exemplo n.º 2
0
Arquivo: test.py Projeto: oscarchs/CMS
 def testarticlemodelpost(self):
     user = User(username="******", email="*****@*****.**", password="******", role=1, status=1)
     db.session.add(user)
     db.session.commit()
     usertest = User.query.filter(User.username == "Testuser").first()
     testarticle = Article(
         title="testtitle",
         body="testbody",
         created="01-01-2015",
         section_name="testname",
         section="testsection",
         user_name=usertest.username,
         user=usertest,
     )
     db.session.add(section_todelete)
     db.session.commit()
     self.assertTrue(testarticle.all() != None)
     self.assertTrue(testarticle.find_by_id() != None)
     self.assertTrue(testarticle.find_by_author(usertest.username) != None)
     self.assertTrue(testarticle.find_by_section("testsection") != None)
     self.assertTrue(testarticle.slug() != None)
     self.assertTrue(testarticle.create_in_words() != None)