forked from Yaltik/golem
Ajout du test de basculement automatique au cas de desincription depuis membre
This commit is contained in:
parent
afc3c3acf9
commit
8dcc29e578
@ -41,6 +41,7 @@ class GolemActivity(models.Model):
|
||||
activity.auto_registration_from_queue = not activity.auto_registration_from_queue
|
||||
|
||||
#supprimer les personnes en attente si une inscription directement est faite
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
""" Override method write to delete record from queue if they register in activity"""
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
""" GOLEM member testing """
|
||||
|
||||
from odoo import exceptions
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
# from psycopg2 import IntegrityError
|
||||
|
||||
@ -29,37 +29,67 @@ class TestGolemMember(TransactionCase):
|
||||
def setUp(self, *args, **kwargs):
|
||||
""" Bootstrap member """
|
||||
super(TestGolemMember, self).setUp(*args, **kwargs)
|
||||
self.data1 = {'lastname': u'LAST1', 'firstname': u'First1'}
|
||||
self.data2 = {'lastname': u'LAST2', 'firstname': u'First2'}
|
||||
self.data3 = {'lastname': u'LAST3', 'firstname': u'First3'}
|
||||
#création du saison
|
||||
self.season = self.env['golem.season'].sudo().create({'name': u'Season 1'})
|
||||
self.season.do_default_season()
|
||||
#préparation des données pour la création des membres
|
||||
self.data_member_1 = {'lastname': u'LAST1',
|
||||
'firstname': u'First1',
|
||||
'season_ids':[(4, self.season.id, False)]
|
||||
}
|
||||
self.data_member_2 = {'lastname': u'LAST2',
|
||||
'firstname': u'First2',
|
||||
'season_ids':[(4, self.season.id, False)]
|
||||
}
|
||||
self.member1 = self.env['golem.member']
|
||||
self.member2 = self.env['golem.member']
|
||||
self.member3 = self.env['golem.member']
|
||||
#préparation des donnée pour la création de l'activité
|
||||
type_id = self.ref("golem_activity.golem_activity_type_activity")
|
||||
self.data_activity = {
|
||||
'name': u'Activity 1',
|
||||
'season_id': self.season.id,
|
||||
'type_id': type_id}
|
||||
self.activity = self.env['golem.activity']
|
||||
|
||||
|
||||
def test_member_creation(self):
|
||||
""" Test member creation """
|
||||
member1 = self.member1.create(self.data1)
|
||||
member1 = self.member1.create(self.data_member_1)
|
||||
#verification que le membre n'est inscrit en aucune attente
|
||||
self.assertFalse(member1.activity_queue_ids)
|
||||
|
||||
"""
|
||||
self.member2 = mcrt({'lastname': u'LAST', 'firstname': u'Young'})
|
||||
self.season = self.env['golem.season'].sudo().create({'name': u'Season 1'})
|
||||
self.data = {
|
||||
'name': u'Activity 1',
|
||||
'season_id': self.season.id,
|
||||
'type_id': type_id
|
||||
}
|
||||
|
||||
|
||||
super(TestGolemMember, self).setUp(*args, **kwargs)
|
||||
self.member_numberconfig_model = self.env['golem.member.numberconfig']
|
||||
season_mdl = self.env['golem.season'].sudo()
|
||||
self.season_current = season_mdl.create({'name': u'Current'})
|
||||
self.season_current.do_default_season()
|
||||
self.season_next = season_mdl.create({'name': u'Next'})
|
||||
self.member_model = self.env['golem.member'].sudo()
|
||||
mcrt = self.member_model.create
|
||||
self.member1 = mcrt({'lastname': u'LAST', 'firstname': u'First'})
|
||||
self.member2 = mcrt({'lastname': u'LAST', 'firstname': u'Young',
|
||||
'birthdate_date': '2016-01-01'})
|
||||
"""
|
||||
def test_automated_registration(self):
|
||||
""" Test automated registration """
|
||||
#création de 2 membre est une activité
|
||||
member1 = self.member1.create(self.data_member_1)
|
||||
member2 = self.member2.create(self.data_member_2)
|
||||
activity = self.activity.create(self.data_activity)
|
||||
#membre 1 inscrit sur activity
|
||||
registration = {
|
||||
'activity_id' : activity.id,
|
||||
'member_id' : member1.id
|
||||
}
|
||||
#memebre 2 inscrit sur attente
|
||||
queue = {
|
||||
'activity_id' : activity.id,
|
||||
'member_id' : member2.id
|
||||
}
|
||||
#Verification que l'atente est le basculement automatique est aactivé
|
||||
self.assertTrue(activity.queue_allowed)
|
||||
self.assertTrue(activity.auto_registration_from_queue)
|
||||
#réduire le nombre de place sur activity à 1
|
||||
activity.write({'places': 1})
|
||||
#enregistrement du membre 1 sur activity et memebre 2 sur attente
|
||||
activity.write({'activity_registration_ids': [(0, False, registration)]})
|
||||
activity.write({'activity_queue_ids': [(0, False, queue)]})
|
||||
#vérification des membre 1 sur registration et membre 2 sur attente
|
||||
self.assertEqual(activity.activity_registration_ids[0].member_id, member1)
|
||||
self.assertEqual(activity.activity_queue_ids[0].member_id, member2)
|
||||
#suppression du membre 1 de l'activity
|
||||
member1.write({'activity_registration_ids': [(2, member1.activity_registration_ids[0].id, False)]})
|
||||
#verifcation de la presence du membre 2 sur activity : basculement depuis attente
|
||||
self.assertEqual(activity.activity_registration_ids[0].member_id, member2)
|
||||
#verification de l'attente est vide
|
||||
self.assertFalse(activity.activity_queue_ids)
|
||||
print "test membre fini __________________________tn "
|
||||
|
Loading…
Reference in New Issue
Block a user