Ejemplo n.º 1
0
    def setUp(self):
        self.app=create_app(TestConfig)
        self.app_context=self.app.app_context()
        self.app_context.push()
        db.create_all()

        
        luna=User()
        luna.username='******'
        luna.firstName='Luna'
        luna.lastName='Lee'
        luna.email='*****@*****.**'
        luna.isAdmin=True

        db.session.add(luna)
        db.session.commit()

        title='where is your favorite fishing spot?'
        description='survey to find out the most favorite fishing spot in Perth'
        user=User.query.filter_by(username='******').first()
        minResponses=5 #if not specified, the default value is -1 which will be ignored
        orderCandidateBy=None #if not specified, the default value is alphabel acending 'Acs'
        isOpenPoll=None #if not specified, the default value is False
        openAt=None #if not specified, the default value is utcnow()
        closeAt=None  # if not specified, the default value is today + 7 days
        poll=Poll(title, description, minResponses, orderCandidateBy, isOpenPoll, openAt, closeAt, user)

        db.session.add(poll)
        db.session.commit()

        candidate1 = Poll.Candidate()
        candidate1.candidateDescription='Narrows Bridge Perth'
        candidate1.displayOrder=None
        candidate1.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate1.isActive=True


        candidate2 = Poll.Candidate()
        candidate2.candidateDescription='White Hills Mandurah'
        candidate2.displayOrder=None
        candidate2.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate2.isActive=True


        candidate3 = Poll.Candidate()
        candidate3.candidateDescription='North Mole Fremantle'
        candidate3.displayOrder=None
        candidate3.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate3.isActive=True


        candidate4 = Poll.Candidate()
        candidate4.candidateDescription='Floreat Drain Floreat'
        candidate4.displayOrder=None
        candidate4.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate4.isActive=True



        candidate5 = Poll.Candidate()
        candidate5.candidateDescription='Ricey Beach And Radar Reef Rottnest Island'
        candidate5.displayOrder=None
        candidate5.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate5.isActive=True


        candidate6 = Poll.Candidate()
        candidate6.candidateDescription='Lancelin Jetty Lancelin'
        candidate6.displayOrder=None
        candidate6.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate6.isActive=True


     
        db.session.add(candidate1)
        db.session.commit()
        db.session.add(candidate2)
        db.session.commit()
        db.session.add(candidate3)
        db.session.commit()
        db.session.add(candidate4)
        db.session.commit()
        db.session.add(candidate5)
        db.session.commit()
        db.session.add(candidate6)
        db.session.commit()
Ejemplo n.º 2
0
    def setUp(self):
        # basedir=os.path.abspath(os.path.dirname(__file__))
        # SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'test.db')
        # self.app=app.test_client()
        self.app=create_app(TestConfig)
        self.app_context=self.app.app_context()
        self.app_context.push()
        db.create_all()
        luna=User()
        luna.username='******'
        luna.firstName='Luna'
        luna.lastName='Lee'
        luna.email='*****@*****.**'
        luna.isAdmin=True
        
        haolin=User()
        haolin.username='******'
        haolin.firstName='abcHaolin'
        haolin.lastName='Wu'
        haolin.email='*****@*****.**'
        haolin.isAdmin=True


        db.session.add(luna)
        db.session.add(haolin)
        db.session.commit()


        title='where is your favorite fishing spot?'
        description='survey to find out the most favorite fishing spot in Perth'
        user=User.query.filter_by(username='******').first()
        minResponses=5 #if not specified, the default value is -1 which will be ignored
        orderCandidateBy=None #if not specified, the default value is alphabel acending 'Acs'
        isOpenPoll=None #if not specified, the default value is False
        openAt=None #if not specified, the default value is utcnow()
        closeAt=None  # if not specified, the default value is today + 7 days
        poll=Poll(title, description, minResponses, orderCandidateBy, isOpenPoll, openAt, closeAt, user)

        db.session.add(poll)
        db.session.commit()

        candidate1 = Poll.Candidate()
        candidate1.candidateDescription='Narrows Bridge Perth'
        candidate1.displayOrder=None
        candidate1.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate1.isActive=True


        candidate2 = Poll.Candidate()
        candidate2.candidateDescription='White Hills Mandurah'
        candidate2.displayOrder=None
        candidate2.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate2.isActive=True


        candidate3 = Poll.Candidate()
        candidate3.candidateDescription='North Mole Fremantle'
        candidate3.displayOrder=None
        candidate3.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate3.isActive=True


        candidate4 = Poll.Candidate()
        candidate4.candidateDescription='Floreat Drain Floreat'
        candidate4.displayOrder=None
        candidate4.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate4.isActive=True



        candidate5 = Poll.Candidate()
        candidate5.candidateDescription='Ricey Beach And Radar Reef Rottnest Island'
        candidate5.displayOrder=None
        candidate5.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate5.isActive=True


        candidate6 = Poll.Candidate()
        candidate6.candidateDescription='Lancelin Jetty Lancelin'
        candidate6.displayOrder=None
        candidate6.pollId=Poll.query.filter_by(pollId=1).first().pollId
        candidate6.isActive=True


     
        db.session.add(candidate1)
        db.session.commit()
        db.session.add(candidate2)
        db.session.commit()
        db.session.add(candidate3)
        db.session.commit()
        db.session.add(candidate4)
        db.session.commit()
        db.session.add(candidate5)
        db.session.commit()
        db.session.add(candidate6)
        db.session.commit()