diff --git a/golem_activity_queue/tests/__init__.py b/golem_activity_queue/tests/__init__.py new file mode 100644 index 0000000..721a338 --- /dev/null +++ b/golem_activity_queue/tests/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 . + +from . import test_golem_activity_queue, test_golem_activity, test_golem_member diff --git a/golem_activity_queue/tests/test_golem_activity.py b/golem_activity_queue/tests/test_golem_activity.py new file mode 100644 index 0000000..027b078 --- /dev/null +++ b/golem_activity_queue/tests/test_golem_activity.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 . + +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) diff --git a/golem_activity_queue/tests/test_golem_activity_queue.py b/golem_activity_queue/tests/test_golem_activity_queue.py new file mode 100644 index 0000000..5363a3c --- /dev/null +++ b/golem_activity_queue/tests/test_golem_activity_queue.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 . + +""" 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) diff --git a/golem_activity_queue/tests/test_golem_member.py b/golem_activity_queue/tests/test_golem_member.py new file mode 100644 index 0000000..9e7c02d --- /dev/null +++ b/golem_activity_queue/tests/test_golem_member.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 . + +""" GOLEM member testing """ + +from odoo import exceptions +from odoo.tests.common import TransactionCase +# from psycopg2 import IntegrityError + + +class TestGolemMember(TransactionCase): + """ GOLEM member testing """