[TESTS] procurement: yml yo new API unit tests

This commit is contained in:
Thibault Delavallée
2016-07-04 16:22:36 +02:00
parent e924881f7c
commit 71aee8e166
5 changed files with 50 additions and 16 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ Procurements in exception should be checked manually and can be re-run.
'views/product_views.xml',
],
'demo': [],
'test': ['test/procurement.yml'],
'test': [],
'installable': True,
'auto_install': True,
}
-15
View File
@@ -1,15 +0,0 @@
-
I create a procurement
-
!record {model: procurement.order, id: procurement_order0}:
company_id: base.main_company
name: Procurement Test
product_id: product.product_delivery_01
product_qty: 15.0
product_uom: product.product_uom_unit
-
I check that procurement order is in exception, as at first there isn't any suitable rule
-
!python {model: procurement.order}: |
proc_order = self.browse(cr, uid, ref('procurement_order0'), context=context)
assert proc_order.state == 'exception'
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
import test_procurement
+27
View File
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
from odoo.addons.product.tests import common
class TestStockCommon(common.TestProductCommon):
def _create_procurement(self, user, **values):
Procurement = self.env['procurement.order'].sudo(user)
procurement = Procurement.new(values)
procurement.onchange_product_id()
return Procurement.create(procurement._convert_to_write(procurement._cache))
@classmethod
def setUpClass(cls):
super(TestStockCommon, cls).setUpClass()
user_group_employee = cls.env.ref('base.group_user')
# User Data: lambda user
Users = cls.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True})
cls.user_employee = Users.create({
'name': 'Fabricette Manivelle',
'login': 'fabricette',
'email': 'f.f@example.com',
'notify_email': 'none',
'groups_id': [(6, 0, [user_group_employee.id])]})
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Author: Leonardo Pistone
# Copyright 2015 Camptocamp SA
from odoo.addons.procurement.tests.common import TestStockCommon
class TestBase(TestStockCommon):
def test_base(self):
procurement = self._create_procurement(
self.user_employee,
product_id=self.product_1.id,
name='Procurement Test',
product_qty=15.0)
# I check that procurement order is in exception, as at first there isn't any suitable rule
self.assertEqual(procurement.state, 'exception')