Esempio n. 1
0
    def test_quiz_post(self):
        data = dict([
            ('weighting-economy-percent', u'30'),
            ('save', u'Next \xbb'),
            ('weighting-education-percent', u'30'),
            ('weighting-health-percent', u'40'),
            ('dimension', '__dimension__')
            ])
        with app.test_client() as c:
            res = c.post('/quiz', data=data)
            userid = g.user_id
            out = db.weighting.find_one({'user_id': userid, 'quiz_id': QUIZ})
            assert out, out
            assert out['sets_done'] == ['__dimension__'], out
            assert out['question_sets']['__dimension__'][0] == [u'economy', 0.30]

            assert res.status == '302 FOUND', res.status
            assert 'quiz/2' in res.data, res.data
Esempio n. 2
0
    def test_quiz(self):
        with app.test_client() as c:
            res =  c.get('/quiz/1')
            assert 'Economy' in res.data, res.data
            assert 'Education' in res.data, res.data
            assert 'Step 1' in res.data, res.data
            assert '__dimension__' in res.data, res.data
            print g.user_id
            assert g.user_id in res.data, res.data
            # Economy weight
            assert 'value="33"' in res.data, res.data
            assert 'value="34"' in res.data, res.data

        res =  self.app.get('/quiz/2')
        assert 'Household final consumption' in res.data, res.data

        res =  self.app.get('/quiz/3')
        assert 'Prevalence of undernourishment' in res.data, res.data

        res =  self.app.get('/quiz/4')
        assert 'Mean years of schooling' in res.data, res.data
Esempio n. 3
0
 def setup(self):
     self.app = app.test_client()
     self.userid = 'testapiuser'
     w = model.Weighting.new(u'yourtopia', self.userid)
     db.weighting.insert(w)
Esempio n. 4
0
 def setup(self):
     self.app = app.test_client()