~unifield-team/unifield-wm/trunk

« back to all changes in this revision

Viewing changes to unifield_tests/tests/test_uf_2507.py

  • Committer: jf
  • Date: 2014-10-20 13:00:51 UTC
  • mfrom: (2298.1.3 unifield-wm)
  • Revision ID: jfb@tempo-consulting.fr-20141020130051-rlwhf420bgg0rw0g
UFTP-319 [FIX] Error message when Deleting line in Tender
lp:~unifield-team/unifield-wm/uftp-319

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf8 -*-
 
3
 
 
4
__author__ = 'qt'
 
5
 
 
6
from resourcing import ResourcingTest
 
7
 
 
8
 
 
9
class UF2507ResourcingTest(ResourcingTest):
 
10
 
 
11
    def test_uf_2507(self):
 
12
        """
 
13
        1/ Create a field order with 4 lines and source all lines
 
14
        in the same PO.
 
15
        2/ Delete the first line.
 
16
        3/ Add a new line without origin set
 
17
        4/ Set the origin on the new line
 
18
        5/ Validate and confirm the PO
 
19
        6/ Check the number of lines in the FO
 
20
        """
 
21
        db = self.used_db
 
22
 
 
23
        # Prepare object
 
24
        c_wiz_model = 'purchase.order.line.unlink.wizard'
 
25
        c_wiz = db.get(c_wiz_model)
 
26
 
 
27
        """
 
28
        1/ Create and source the first FO
 
29
        """
 
30
        order_id, order_line_ids, po_ids, po_line_ids = self.order_source_all_one_po(db)
 
31
 
 
32
        # Check number of generated PO and PO lines
 
33
        self.assertEqual(
 
34
            len(po_ids),
 
35
            1,
 
36
            "Number of generated PO : %s - Should be 1" % len(po_ids),
 
37
        )
 
38
        self.assertEqual(
 
39
            len(po_line_ids),
 
40
            4,
 
41
            "Number of lines generated in PO : %s - Should be 4" % len(po_line_ids),
 
42
        )
 
43
 
 
44
        """
 
45
        2/ Delete the first line of the PO
 
46
        """
 
47
        c_res = self.pol_obj.ask_unlink(po_line_ids[0])
 
48
 
 
49
        # Check display of cancel wizard
 
50
        self.assert_(
 
51
            c_res.get('res_id'),
 
52
            "No wizard returned by the cancellation of the PO line",
 
53
        )
 
54
        self.assert_(
 
55
            c_res.get('res_model') == c_wiz_model,
 
56
            "The model returned by the cancellation of the PO line is not good",
 
57
        )
 
58
 
 
59
        c_wiz.just_cancel(c_res.get('res_id'))
 
60
 
 
61
        # Check the PO line has been removed
 
62
        po_line_ids = self.po_obj.read(po_ids[0], ['order_line'])['order_line']
 
63
        self.assert_(
 
64
            len(po_line_ids) == 3,
 
65
            "The line has not been removed well on the PO (%s - should be 3)" % len(po_line_ids),
 
66
        )
 
67
        # Check the FO line has been removed
 
68
        self.assert_(
 
69
            self._get_number_of_valid_lines(db, order_id) == 3,
 
70
            "The line has not been removed well on the FO",
 
71
        )
 
72
 
 
73
        """
 
74
        3/ Add a new line without origin set
 
75
        """
 
76
        ana_distrib_id = self.pol_obj.read(po_line_ids[1], ['analytic_distribution_id'])['analytic_distribution_id']
 
77
        if not ana_distrib_id:
 
78
            ana_distrib_id = self.get_record(db, 'distrib_1')
 
79
        else:
 
80
            ana_distrib_id = ana_distrib_id[0]
 
81
        line_values = {
 
82
            'order_id': po_ids[0],
 
83
            'product_id': self.get_record(db, 'prod_log_1'),
 
84
            'product_uom': self.get_record(db, 'product_uom_unit', module='product'),
 
85
            'product_qty': 123,
 
86
            'price_unit': 01.20,
 
87
            'analytic_distribution_id': ana_distrib_id,
 
88
        }
 
89
        new_pol_id = self.pol_obj.create(line_values)
 
90
 
 
91
        # Check the PO line has been added well
 
92
        po_line_ids = self.po_obj.read(po_ids[0], ['order_line'])['order_line']
 
93
        self.assert_(
 
94
            len(po_line_ids) == 4,
 
95
            "Number of lines generated in PO : %s - Should be 4" % len(po_line_ids),
 
96
        )
 
97
 
 
98
        """
 
99
        4/ Set the origin on the new line
 
100
        """
 
101
        order_name = self.order_obj.read(order_id, ['name'])['name']
 
102
        self.pol_obj.write(new_pol_id, {'origin': order_name})
 
103
 
 
104
        """
 
105
        5/ Validate and confirm the PO
 
106
        """
 
107
        self._validate_po(db, po_ids)
 
108
        self._confirm_po(db, po_ids)
 
109
 
 
110
 
 
111
        """
 
112
        6/ Check the number of lines in the FO/IR
 
113
        """
 
114
        # Check the FO line has been added
 
115
        fo_lines_nb = self._get_number_of_valid_lines(db, order_id)
 
116
        self.assert_(
 
117
            fo_lines_nb == 4,
 
118
            "The line has not been added well on the order (%s - should be 4)" % fo_lines_nb,
 
119
        )
 
120
 
 
121
 
 
122
class UF2507FOResourcingTest(UF2507ResourcingTest):
 
123
 
 
124
    def setUp(self):
 
125
        self.pr = False
 
126
        super(UF2507FOResourcingTest, self).setUp()
 
127
 
 
128
 
 
129
class UF2507IRResourcingTest(UF2507ResourcingTest):
 
130
 
 
131
    def setUp(self):
 
132
        self.pr = True
 
133
        super(UF2507IRResourcingTest, self).setUp()
 
134
 
 
135
 
 
136
 
 
137
def get_test_suite():
 
138
    '''Return the class to use for tests'''
 
139
    return UF2507FOResourcingTest, UF2507IRResourcingTest
 
 
b'\\ No newline at end of file'