2018-02-28 23:31:30 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
|
|
|
|
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-03-06 07:31:41 +01:00
|
|
|
""" GOLEM Member testing """
|
2018-03-02 18:16:06 +01:00
|
|
|
|
2018-02-28 23:31:30 +01:00
|
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
|
|
|
|
|
|
class TestGolemMember(TransactionCase):
|
|
|
|
""" GOLEM member testing """
|
2018-03-02 14:37:08 +01:00
|
|
|
|
|
|
|
def setUp(self, *args, **kwargs):
|
|
|
|
""" Bootstrap member """
|
|
|
|
super(TestGolemMember, self).setUp(*args, **kwargs)
|
2018-03-02 18:16:06 +01:00
|
|
|
#création du saison
|
2018-03-07 11:07:25 +01:00
|
|
|
self.season = self.env['golem.season'].create({'name': u'Season 1'})
|
2018-03-02 18:16:06 +01:00
|
|
|
self.data_member_1 = {'lastname': u'LAST1',
|
|
|
|
'firstname': u'First1',
|
2018-03-07 11:07:25 +01:00
|
|
|
'season_ids':[(4, self.season.id, False)]}
|
2018-03-02 18:16:06 +01:00
|
|
|
self.data_member_2 = {'lastname': u'LAST2',
|
|
|
|
'firstname': u'First2',
|
2018-03-07 11:07:25 +01:00
|
|
|
'season_ids':[(4, self.season.id, False)]}
|
|
|
|
self.member = self.env['golem.member']
|
|
|
|
type_id = self.env.ref('golem_activity.golem_activity_type_activity')
|
2018-03-02 18:16:06 +01:00
|
|
|
self.data_activity = {
|
|
|
|
'name': u'Activity 1',
|
|
|
|
'season_id': self.season.id,
|
2018-03-07 11:07:25 +01:00
|
|
|
'type_id': type_id.id
|
|
|
|
}
|
2018-03-02 18:16:06 +01:00
|
|
|
self.activity = self.env['golem.activity']
|
2018-03-07 11:07:25 +01:00
|
|
|
self.activity_registration = self.env['golem.activity.registration']
|
|
|
|
self.activity_queue = self.env['golem.activity.queue']
|
2018-03-02 14:37:08 +01:00
|
|
|
|
|
|
|
def test_member_creation(self):
|
2018-03-07 11:07:25 +01:00
|
|
|
""" Test member queue default """
|
|
|
|
member1 = self.member.create(self.data_member_1)
|
2018-03-02 14:37:08 +01:00
|
|
|
self.assertFalse(member1.activity_queue_ids)
|
|
|
|
|
2018-03-02 18:16:06 +01:00
|
|
|
def test_automated_registration(self):
|
|
|
|
""" Test automated registration """
|
2018-03-07 11:07:25 +01:00
|
|
|
member1 = self.member.create(self.data_member_1)
|
|
|
|
member2 = self.member.create(self.data_member_2)
|
2018-03-02 18:16:06 +01:00
|
|
|
activity = self.activity.create(self.data_activity)
|
2018-03-07 11:07:25 +01:00
|
|
|
|
|
|
|
registration_data = {'activity_id' : activity.id, 'member_id' : member1.id}
|
|
|
|
queue_data = {'activity_id' : activity.id, 'member_id' : member2.id}
|
2018-03-02 18:16:06 +01:00
|
|
|
self.assertTrue(activity.queue_allowed)
|
|
|
|
self.assertTrue(activity.auto_registration_from_queue)
|
2018-03-07 11:07:25 +01:00
|
|
|
|
|
|
|
activity.places = 1
|
|
|
|
registration = self.activity_registration.create(registration_data)
|
|
|
|
self.activity_queue.create(queue_data)
|
|
|
|
|
2018-03-02 18:16:06 +01:00
|
|
|
self.assertEqual(activity.activity_registration_ids[0].member_id, member1)
|
|
|
|
self.assertEqual(activity.activity_queue_ids[0].member_id, member2)
|
2018-03-07 11:07:25 +01:00
|
|
|
|
|
|
|
registration.unlink()
|
2018-03-02 18:16:06 +01:00
|
|
|
self.assertEqual(activity.activity_registration_ids[0].member_id, member2)
|
|
|
|
self.assertFalse(activity.activity_queue_ids)
|