Link to transport
This commit is contained in:
@@ -219,27 +219,33 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
'planned_to_location': 20,
|
||||
})
|
||||
|
||||
def test_lot_shipping_create_shipment_links_planned_locations(self):
|
||||
'link to transport creates shipment in and links planned locations'
|
||||
def test_lot_shipping_link_creates_shipment_from_dialog_supplier(self):
|
||||
'link to transport creates shipment in from dialog supplier'
|
||||
wizard = lot_module.LotShipping()
|
||||
supplier = Mock(id=30)
|
||||
created_shipment = Mock(id=40)
|
||||
ShipmentIn = Mock()
|
||||
ShipmentIn.create.return_value = [created_shipment]
|
||||
wizard.records = [Mock(r_supplier=supplier)]
|
||||
wizard.records = []
|
||||
wizard.ship = Mock(
|
||||
shipment='in',
|
||||
shipment_in=None,
|
||||
shipment_out=None,
|
||||
shipment_internal=None,
|
||||
create_new_shipment=True,
|
||||
shipment_supplier=supplier,
|
||||
planned_from_location=Mock(id=10),
|
||||
planned_to_location=Mock(id=20),
|
||||
)
|
||||
|
||||
with patch('trytond.modules.purchase_trade.lot.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.return_value = ShipmentIn
|
||||
with patch.object(
|
||||
wizard, 'transition_shipping', return_value='end'
|
||||
) as transition_shipping:
|
||||
state = wizard.transition_create_shipment()
|
||||
Lot = Mock()
|
||||
Lot.skip_quantity_consistency.return_value.__enter__ = Mock()
|
||||
Lot.skip_quantity_consistency.return_value.__exit__ = Mock()
|
||||
pool = Mock()
|
||||
pool.get.side_effect = [Lot, Mock(), Mock(), ShipmentIn]
|
||||
with patch('trytond.modules.purchase_trade.lot.Pool',
|
||||
return_value=pool):
|
||||
state = wizard.transition_shipping()
|
||||
|
||||
self.assertEqual(state, 'end')
|
||||
ShipmentIn.create.assert_called_once_with([{
|
||||
@@ -248,7 +254,22 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
'to_location': 20,
|
||||
}])
|
||||
self.assertEqual(wizard.ship.shipment_in, created_shipment)
|
||||
transition_shipping.assert_called_once_with()
|
||||
Lot.assert_lines_quantity_consistency.assert_called_once_with([])
|
||||
|
||||
def test_lot_shipping_rejects_existing_and_new_shipment(self):
|
||||
'link to transport rejects choosing existing shipment and create new'
|
||||
wizard = lot_module.LotShipping()
|
||||
wizard.ship = Mock(
|
||||
shipment='in',
|
||||
shipment_in=Mock(id=40),
|
||||
shipment_out=None,
|
||||
shipment_internal=None,
|
||||
create_new_shipment=True,
|
||||
shipment_supplier=Mock(id=30),
|
||||
)
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
wizard.transition_shipping()
|
||||
|
||||
@with_transaction()
|
||||
def test_get_mtm_applies_component_ratio_as_percentage(self):
|
||||
|
||||
Reference in New Issue
Block a user