class TestOpinion(unittest.TestCase): def setUp(self): """Call before every test case.""" d = {u'name': u'NEEL KASHKARI', u'description': u'Party Preference: Republican\nBusinessman'} c = Contestant(d) self.object = Opinion(c, 1, authoritative=True) def test_opinion_to_json(self): print(self.object.to_json()) self.object.to_json()
def set_form_contest(self): """sets the contest data """ if self.contest_id: try: self.contest = db.get_contest(self.contest_id) except: log.error("Contest ID: {0} not found".format(self.contest_id)) self.contest_id = '' elif self.contests: ##get first contest from first group if self.contest_groups and self.contest_groups[0]['contests']: self.contest = self.contest_groups[0]['contests'][0] else: self.contest = self.contests[0] if self.contest: self.contest_id = self.contest.id if self.contest: def get_decisions(): return db.get_contest_decisions(self.contest) #eventually we got to only return only a page of opinions at a time, #but we don't have a real database yet so we have to do our summaries manually in code #we don't want to cache for the demo we want results right away. # self.contest.decisions = helpers.get_cache(cache, 'all_decisions_{0}'.format(self.contest.id), # get_decisions, 300) self.contest.decisions = get_decisions() self.all_opinions = self.contest.get_all_opinions() self.official_opinions = self.contest.get_official_opinions() self.all_opinion_summary = Opinion.get_opinion_summary( self.all_opinions, self.contest.contestants,self.contest.decision_type, self.contest.allow_write_ins) self.official_opinion_summary = Opinion.get_opinion_summary( self.official_opinions, self.contest.contestants, self.contest.decision_type, self.contest.allow_write_ins)
def setUp(self): """Call before every test case.""" d = {u'name': u'NEEL KASHKARI', u'description': u'Party Preference: Republican\nBusinessman'} c = Contestant(d) self.object = Opinion(c, 1, authoritative=True)