Skip to content

Commit

Permalink
[WIP] Add test to check when computation fail
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Oct 29, 2023
1 parent e750e78 commit fc5164d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 8 additions & 0 deletions joint_buying_product/demo/joint_buying_transport_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@
<field name="manual_total_weight">70</field>
</record>

<record id="request_vev_fumet_dombes" model="joint.buying.transport.request">
<field name="manual_origin_partner_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_VEV').joint_buying_partner_id.id"/>
<field name="manual_destination_partner_id" ref="joint_buying_base.supplier_fumet_dombes"/>
<field name="manual_start_date" eval="(DateTime.today() + relativedelta(day=8)).strftime('%Y-%m-%d 10:00')"/>
<field name="manual_amount_untaxed">111</field>
<field name="manual_total_weight">66</field>
</record>

</odoo>
19 changes: 15 additions & 4 deletions joint_buying_product/tests/test_joint_buying_transport_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,44 @@ def test_10_joint_buying_grouped_order_generate_transport_request(self):
self.assertFalse(LSE_order.request_id)

def test_20_transport_request_vev_cda(self):
self._test_verify_request(
self._verify_tour_lines_computation(
"joint_buying_product.request_vev_cda",
["joint_buying_base.tour_lyon_loire_1_line_4"],
"computed",
)

def test_21_transport_request_vev_che(self):
self._test_verify_request(
self._verify_tour_lines_computation(
"joint_buying_product.request_vev_che",
[
"joint_buying_base.tour_lyon_loire_1_line_4",
"joint_buying_base.tour_lyon_loire_1_line_6",
"joint_buying_base.tour_lyon_drome_1_line_2",
"joint_buying_base.tour_lyon_drome_1_line_4",
],
"computed",
)

def test_22_transport_request_vev_edc(self):
self._test_verify_request(
self._verify_tour_lines_computation(
"joint_buying_product.request_vev_edc",
[
"joint_buying_base.tour_lyon_loire_1_line_4",
"joint_buying_base.tour_lyon_loire_1_line_6",
"joint_buying_base.tour_lyon_savoie_1_line_2",
"joint_buying_base.tours_savoie_1_line_2",
],
"computed",
)

def _test_verify_request(self, request_xml_id, tour_line_xml_ids):
def test_23_transport_request_vev_fumet(self):
self._verify_tour_lines_computation(
"joint_buying_product.request_vev_fumet_dombes", [], "not_computable"
)

def _verify_tour_lines_computation(
self, request_xml_id, tour_line_xml_ids, expected_state
):
transport_request = self.env.ref(request_xml_id)
wizard = (
self.env["joint.buying.wizard.find.route"]
Expand All @@ -73,3 +83,4 @@ def _test_verify_request(self, request_xml_id, tour_line_xml_ids):
tour_line_ids.append(self.env.ref(line_xml_id).id)

self.assertEqual(transport_request.tour_line_ids.ids, tour_line_ids)
self.assertEqual(transport_request.state, expected_state)

0 comments on commit fc5164d

Please sign in to comment.