-
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] base_delivery_carrier_files: tests to Python tests
- Loading branch information
1 parent
0ce8cdc
commit 47cb896
Showing
6 changed files
with
110 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
from . import csv_writer | ||
from . import generator | ||
from . import models | ||
from . import tests | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2012 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_base_delivery_carrier_files |
104 changes: 104 additions & 0 deletions
104
base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2012 Guewen Baconnier | ||
# Copyright 2018 Sunflower IT (http://sunflowerweb.nl) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import tempfile | ||
|
||
from openerp.tests.common import TransactionCase | ||
|
||
|
||
class CarrierFilesTest(TransactionCase): | ||
|
||
def test_carrier_file_generation(self): | ||
""" Test carrier file generation """ | ||
# I configure the carrier file configuration | ||
# to write to the root document directory. | ||
carrier_file = self.env.ref( | ||
'base_delivery_carrier_files.delivery_carrier_file') | ||
carrier_file.write({ | ||
'export_path': tempfile.gettempdir(), | ||
'write_mode': 'disk' | ||
}) | ||
|
||
# I set the carrier file configuration on the carrier | ||
# 'Free delivery charges' | ||
carrier = self.env.ref('delivery.delivery_carrier') | ||
carrier.carrier_file_id = carrier_file.id | ||
|
||
# I confirm outgoing shipment of 130 kgm Ice-cream. | ||
picking = self.env.ref( | ||
'base_delivery_carrier_files.outgoing_shipment_carrier_file') | ||
picking.action_confirm() | ||
|
||
# I check outgoing shipment after stock availablity in refrigerator. | ||
picking.force_assign() | ||
|
||
# I deliver outgoing shipment. | ||
wizard = self.env['stock.transfer_details'].with_context({ | ||
'active_model': 'stock.picking', | ||
'active_id': picking.id, | ||
'active_ids': picking.ids | ||
}).create({ | ||
'picking_id': picking.id | ||
}) | ||
wizard.do_detailed_transfer() | ||
|
||
# I check shipment details after shipment | ||
# The carrier file must have been generated. | ||
self.assertTrue(picking.carrier_file_generated) | ||
|
||
# I check outgoing shipment copy | ||
# The carrier_file_generated field must be unchecked. | ||
new_picking = picking.copy() | ||
self.assertFalse(new_picking.carrier_file_generated) | ||
|
||
def test_manual_carrier_file_generation(self): | ||
""" Test manual carrier file generation """ | ||
# I configure the carrier file configuration | ||
# to write to the root document directory. | ||
carrier_file = self.env.ref( | ||
'base_delivery_carrier_files.delivery_carrier_file') | ||
carrier_file.write({ | ||
'export_path': tempfile.gettempdir(), | ||
'write_mode': 'disk' | ||
}) | ||
|
||
# I set the carrier file configuration on the carrier | ||
# 'Free delivery charges' | ||
carrier = self.env.ref('delivery.delivery_carrier') | ||
carrier.carrier_file_id = carrier_file.id | ||
|
||
# I confirm outgoing shipment of 130 kgm Ice-cream. | ||
picking = self.env.ref( | ||
'base_delivery_carrier_files' | ||
'.outgoing_shipment_carrier_file_manual') | ||
picking.action_confirm() | ||
|
||
# I check outgoing shipment after stock availablity in refrigerator. | ||
picking.force_assign() | ||
|
||
# I deliver outgoing shipment. | ||
wizard = self.env['stock.transfer_details'].with_context({ | ||
'active_model': 'stock.picking', | ||
'active_id': picking.id, | ||
'active_ids': picking.ids | ||
}).create({ | ||
'picking_id': picking.id | ||
}) | ||
wizard.do_detailed_transfer() | ||
|
||
# I check shipment details after shipment | ||
# The carrier file must NOT have been generated. | ||
self.assertFalse(picking.carrier_file_generated) | ||
|
||
# I generate the carrier files of my shipment from the wizard | ||
wizard = self.env['delivery.carrier.file.generate'].with_context({ | ||
'active_ids': picking.ids, | ||
'active_model': 'stock.picking' | ||
}).create({}) | ||
wizard.action_generate() | ||
|
||
# I check shipment details after manual generation | ||
# The carrier file must have been generated. | ||
self.assertTrue(picking.carrier_file_generated) |