forked from Yaltik/golem
Ajout des initiations en test unitaire
This commit is contained in:
parent
4fda12364f
commit
375fe6b552
19
golem_activity_queue/tests/__init__.py
Normal file
19
golem_activity_queue/tests/__init__.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- 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/>.
|
||||
|
||||
from . import test_golem_activity_queue, test_golem_activity, test_golem_member
|
48
golem_activity_queue/tests/test_golem_activity.py
Normal file
48
golem_activity_queue/tests/test_golem_activity.py
Normal file
@ -0,0 +1,48 @@
|
||||
# -*- 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/>.
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.models import ValidationError
|
||||
|
||||
|
||||
class TestGolemActivity(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestGolemActivity, self).setUp()
|
||||
|
||||
self.season_model = self.env['golem.season'].sudo()
|
||||
season_data = {'name': u'Current', 'date_start': '2010-01-01',
|
||||
'date_end': '2010-12-31'}
|
||||
self.season_current = self.season_model.create(season_data)
|
||||
self.activity_model = self.env['golem.activity'].sudo()
|
||||
|
||||
def test_activity_creation(self):
|
||||
""" Test creation of activity and periods """
|
||||
categ = self.ref('golem_activity.golem_product_category_activities')
|
||||
adata = {'name': 'a1', 'season_id': self.season_current.id,
|
||||
'categ_id': categ}
|
||||
a1 = self.activity_model.create(adata)
|
||||
a1.onchange_season_dates()
|
||||
self.assertEqual(a1.name, 'a1')
|
||||
self.assertEqual(a1.date_start, self.season_current.date_start)
|
||||
self.assertEqual(a1.date_end, self.season_current.date_end)
|
||||
self.assertTrue(a1.is_current)
|
||||
adata.update({'name': 'a2', 'date_start': '2010-01-01',
|
||||
'date_end': '2009-12-01'})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.activity_model.create(adata)
|
55
golem_activity_queue/tests/test_golem_activity_queue.py
Normal file
55
golem_activity_queue/tests/test_golem_activity_queue.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- 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/>.
|
||||
|
||||
""" GOLEM Activity Queue testing """
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestGolemActivityQueue(TransactionCase):
|
||||
""" GOLEM Activity Queue testing """
|
||||
|
||||
def setUp(self, *args, **kwargs):
|
||||
""" Bootstrap Resource """
|
||||
super(TestGolemActivityQueue, self).setUp(*args, **kwargs)
|
||||
|
||||
self.season = self.env['golem.season'].sudo().create({'name': u'Season 1'})
|
||||
categ = self.ref('golem_activity.golem_product_category_activities')
|
||||
self.activity = self.env['golem.activity'].create({'name': u'Activity 1',
|
||||
'season_id': self.season,
|
||||
'categ_id': categ})
|
||||
self.member = self.env['golem.member'].create({
|
||||
'lastname': u'LAST',
|
||||
'firstname': u'First'
|
||||
})
|
||||
self.data = {
|
||||
'activity_id': self.activity.id,
|
||||
'member_id': self.member.id,
|
||||
'avaibility_start': '2018-01-01',
|
||||
'avaibility_stop': '2020-01-01'
|
||||
}
|
||||
self.activity_queue_obj = self.env['golem.activity.queue']
|
||||
|
||||
def test_activity_queue_basic(self):
|
||||
""" Test activity queue bases """
|
||||
activity_queue = self.activity_queue_obj.create(self.data)
|
||||
self.assertEqual(activity_queue.member_id, self.member)
|
||||
self.assertEqual(activity_queue.activity_id, self.activity)
|
||||
self.assertEqual(activity_queue.activity_id.activity_queue_ids[0], activity_queue)
|
||||
self.assertEqual(activity_queue.places_remain, self.activity.places_remain)
|
27
golem_activity_queue/tests/test_golem_member.py
Normal file
27
golem_activity_queue/tests/test_golem_member.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- 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/>.
|
||||
|
||||
""" GOLEM member testing """
|
||||
|
||||
from odoo import exceptions
|
||||
from odoo.tests.common import TransactionCase
|
||||
# from psycopg2 import IntegrityError
|
||||
|
||||
|
||||
class TestGolemMember(TransactionCase):
|
||||
""" GOLEM member testing """
|
Loading…
Reference in New Issue
Block a user