Ajout des initiations en test unitaire

This commit is contained in:
eloyoussef 2018-02-28 23:31:30 +01:00
parent 4fda12364f
commit 375fe6b552
4 changed files with 149 additions and 0 deletions

View 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

View 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)

View 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)

View 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 """