Commits

Raimon Esteve (Zikzakmedia) committed 1a1f62e

Refactorization test

Comments (0)

Files changed (1)

tests/test_product_price_list_formula.py

 from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view,\
     test_depends
 from trytond.transaction import Transaction
+from decimal import Decimal
 
 class ProductPriceListFormulaTestCase(unittest.TestCase):
     '''
         '''
         with Transaction().start(DB_NAME, USER,
                 context=CONTEXT) as transaction:
-            currency1_id = self.currency.create({
+            currency1 = self.currency.create({
                 'name': 'Currency',
                 'symbol': 'C',
                 'code': 'CUR'
                 })
-            self.assert_(currency1_id)
+            self.assert_(currency1)
 
-            company1_id = self.company.create({
+            company1 = self.company.create({
                 'name': 'Zikzakmedia',
-                'currency': currency1_id,
+                'currency': currency1,
                 })
-            self.assert_(company1_id)
+            self.assert_(company1)
 
             transaction.cursor.commit()
 
         Create Product
         '''
         with Transaction().start(DB_NAME, USER, context=CONTEXT) as transaction:
-            cat_obj = POOL.get('product.category')
-            cat_id = cat_obj.create({'name': 'Toys'})
-            self.assert_(cat_id)
+            Category = POOL.get('product.category')
+            category = Category.create({'name': 'Toys'})
+            self.assert_(category)
 
-            uom_obj = POOL.get('product.uom')
-            values = {
-                'name': 'unit',
-                'symbol': 'u',
-                'category': cat_id,
-                'rate': 1,
-                'factor': 1,
-                'rounding': 2,
-                'digits': 2,
-            }
-            uom_id = uom_obj.create(values)
-            self.assert_(uom_id)
-
-            prod_obj = POOL.get('product.product')
-            values = {
-                'name': 'Ball',
-                'list_price': '45.32',
-                'cost_price': '35.32',
-                'type': 'goods',
-                'default_uom': uom_id,
-                'cost_price_method': 'fixed',
-                'code':'BALL',
-                'salable': True,
-            }
-            prod_id = prod_obj.create(values)
-            self.assert_(prod_id)
+            uom, = self.uom.search([
+                    ('name', '=', 'Unit'),
+                    ])
+            product = self.product.create({
+                    'name': 'Carrier',
+                    'default_uom': uom.id,
+                    'category': category.id,
+                    'type': 'service',
+                    'list_price': Decimal(0),
+                    'cost_price': Decimal(0),
+                    })
+            self.assert_(product)
             transaction.cursor.commit()
 
     def test0030price_list(self):
         Create Price List
         '''
         with Transaction().start(DB_NAME, USER, context=CONTEXT) as transaction:
-            company1_id = self.currency.search([], 0, 1, None)[0]
+            company1 = self.currency.search([], 0, 1, None)[0]
             with transaction.set_user(0):
-                price_list1_id = self.price_list.create({
+                price_list1 = self.price_list.create({
                     'name': 'General Price List',
-                    'company': company1_id,
+                    'company': company1.id,
                     'lines': [
                         ('create', {
                             'formula': 'product.cost_price*1.10',
                         ),],
                     })
 
-                self.assert_(price_list1_id)
+                self.assert_(price_list1)
 
             transaction.cursor.commit()