Ejemplo n.º 1
0
 def test_load_1(self):
     v = votation_dao.votation_dto()
     v.votation_description = 'Guar automated test ' + str(random.randint(1,500))
     v.votation_type = 'random'
     v.promoter_user.user_id = 2
     v.begin_date = '2018-01-01'
     v.end_date = '2018-01-15'
     v.votation_status = 1
     votation_dao.insert_votation_dto(v)
     g = guarantor.guarantor_dto()
     g.votation_id = v.votation_id
     g.u.user_id = 1
     g.hash_ok = 1
     g.passphrase_ok = 0
     guarantor.insert_dto(g)
     g = guarantor.guarantor_dto()
     g.votation_id = v.votation_id
     g.u.user_id = 3
     g.hash_ok = 0
     g.passphrase_ok = 0
     guarantor.insert_dto(g)
     g1 = guarantor.load_guarantor(v.votation_id, g.u.user_id)
     self.assertEqual(g.votation_id, g1.votation_id)
     self.assertEqual(g.u.user_id , g1.u.user_id )
     self.assertEqual(g.hash_ok , g1.hash_ok )
     self.assertEqual(g.passphrase_ok , g1.passphrase_ok )
Ejemplo n.º 2
0
 def test_validate_4(self):
     o = guarantor.guarantor_dto()
     o.votation_id = 1
     o.u.user_id = 1
     o.passphrase_ok = 0
     o.hash_ok = 0
     self.assertEqual(0,guarantor.validate_dto(o))
Ejemplo n.º 3
0
 def test_hash_complete_no_2(self):
     v = votation_dao.votation_dto()
     v.votation_description = 'Guar automated test ' + str(random.randint(1,500))
     v.votation_type = 'random'
     v.promoter_user.user_id = 2
     v.begin_date = '2018-01-01'
     v.end_date = '2018-01-15'
     v.votation_status = 1
     votation_dao.insert_votation_dto(v)
     g = guarantor.guarantor_dto()
     g.votation_id = v.votation_id
     g.u.user_id = 1
     g.hash_ok = 1
     g.passphrase_ok = 0
     guarantor.insert_dto(g)
     g = guarantor.guarantor_dto()
     g.votation_id = v.votation_id
     g.u.user_id = 3
     g.hash_ok = 0
     g.passphrase_ok = 0
     guarantor.insert_dto(g)
     self.assertFalse(guarantor.guarantors_hash_complete(v.votation_id))
Ejemplo n.º 4
0
def be_a_guarantor_confirm():
    votation_id = int(request.args.get('votation_id'))
    v = votation.load_votation_by_id(votation_id)
    message = "Adesso sei un custode."
    o = guarantor.guarantor_dto()
    #app.logger.info(o)
    o.votation_id = votation_id
    o.u = current_user.u
    o.hash_ok = 0
    o.passphrase_ok = 0
    error = guarantor.validate_dto(o)
    if error == 0:
        guarantor.insert_dto(o)
    else:
        message = guarantor.error_messages[
            error] + ": " + v.votation_description
    return render_template('be_a_guarantor_confirm_template.html',
                           pagetitle="Guarantor confirm",
                           v=v,
                           message=message)
Ejemplo n.º 5
0
 def test_validate_1(self):
     o = guarantor.guarantor_dto()
     o.votation_id = 1
     self.assertEqual(1,guarantor.validate_dto(o))
Ejemplo n.º 6
0
 def test_validate_5(self):
     o = guarantor.guarantor_dto()
     o.votation_id = 999 # don't exist
     o.u.user_id = 1
     self.assertEqual(4,guarantor.validate_dto(o))
Ejemplo n.º 7
0
 def test_validate_3(self):
     o = guarantor.guarantor_dto()
     o.votation_id = 1
     o.u.user_id = 999
     self.assertEqual(3,guarantor.validate_dto(o))
Ejemplo n.º 8
0
 def test_validate_2(self):
     o = guarantor.guarantor_dto()
     o.votation_id = None
     o.u.user_id = 1
     self.assertEqual(2,guarantor.validate_dto(o))