Skip to content

Commit

Permalink
[MIG] base_delivery_carrier_files: tests to Python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb authored and mFlayyan committed May 15, 2019
1 parent 0ce8cdc commit 47cb896
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 108 deletions.
1 change: 1 addition & 0 deletions base_delivery_carrier_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
from . import csv_writer
from . import generator
from . import models
from . import tests
from . import wizards
4 changes: 0 additions & 4 deletions base_delivery_carrier_files/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
'demo/carrier_file_demo.xml',
'demo/carrier_file_demo.yml'
],
'test': [
'test/carrier_file.yml',
'test/carrier_file_manual.yml'
],
'images': [],
'installable': True,
'auto_install': False,
Expand Down
47 changes: 0 additions & 47 deletions base_delivery_carrier_files/test/carrier_file.yml

This file was deleted.

57 changes: 0 additions & 57 deletions base_delivery_carrier_files/test/carrier_file_manual.yml

This file was deleted.

5 changes: 5 additions & 0 deletions base_delivery_carrier_files/tests/__init__.py
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 base_delivery_carrier_files/tests/test_base_delivery_carrier_files.py
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)

0 comments on commit 47cb896

Please sign in to comment.