Пример #1
0
 def test_add_vote(self):
     db.add_votes([self.vote_data], self.session, defaultdict(set))
     for model in [db.WorkingYear, db.Constituency, db.Person,
                   db.Votation, db.Vote]:
         self.assertEqual(
             self.session.query(model).filter().count(), 1, model
         )
Пример #2
0
    def test_vote_relationships_work(self):
        db.add_votes([self.vote_data], self.session, defaultdict(set))
        vote = (self.session.query(db.Vote)
                .filter(db.Vote.person_id == '0584386800218').first())

        self.assertEqual(vote.person.first_name, 'Gunnar')
        self.assertEqual(vote.votation.name, 'UBU7')
        self.assertEqual(vote.constituency.name, 'Stockholms kommun')
Пример #3
0
    def test_vote_relationships_work(self):
        db.add_votes([self.vote_data], self.session, defaultdict(set))
        vote = (self.session.query(
            db.Vote).filter(db.Vote.person_id == '0584386800218').first())

        self.assertEqual(vote.person.first_name, 'Gunnar')
        self.assertEqual(vote.votation.name, 'UBU7')
        self.assertEqual(vote.constituency.name, 'Stockholms kommun')
Пример #4
0
 def test_add_vote(self):
     db.add_votes([self.vote_data], self.session, defaultdict(set))
     for model in [
             db.WorkingYear, db.Constituency, db.Person, db.Votation,
             db.Vote
     ]:
         self.assertEqual(
             self.session.query(model).filter().count(), 1, model)
Пример #5
0
    def test_add_mass_votes(self):
        for file_name in ['75F2D01D-4EE1-11D7-AE75-006008577F08',
                          '75302AFA-9423-469E-8432-592DB4A4243F']:
            data = json.load(
                open('tests/fixtures/votation-{0}.json'.format(file_name)))
            if 'votering' in data: data = data['votering']['dokvotering']
            db.add_votes(data, self.session)

        self.longMessage = True
        session = self.session
        for model, expected in [(db.WorkingYear, 2),
                                (db.Constituency, 29),
                                (db.Person, 360),
                                (db.Votation, 2),
                                (db.Vote, 698)]:
            self.assertEqual(session.query(model).filter().count(), expected,
                             model)
Пример #6
0
    def test_add_mass_votes(self):
        for file_name in [
                '75F2D01D-4EE1-11D7-AE75-006008577F08',
                '75302AFA-9423-469E-8432-592DB4A4243F'
        ]:
            data = json.load(
                open('tests/fixtures/votation-{0}.json'.format(file_name)))
            if 'votering' in data: data = data['votering']['dokvotering']
            db.add_votes(data, self.session)

        self.longMessage = True
        session = self.session
        for model, expected in [(db.WorkingYear, 2), (db.Constituency, 29),
                                (db.Person, 360), (db.Votation, 2),
                                (db.Vote, 698)]:
            self.assertEqual(
                session.query(model).filter().count(), expected, model)