def test_only_empty_space_can_be_unassigned_from_a_warehouse(): warehouse = Warehouse("Bodega 1") rnd_space_sku1 = random_space('o1') rnd_space_sku2 = random_space('o2') espacio1 = Space(reference=rnd_space_sku1, max_weigth=50, max_vol=1) espacio2 = Space(reference=rnd_space_sku2, max_weigth=50, max_vol=1) warehouse.add_space(espacio1) warehouse.add_space(espacio2) assert warehouse.list_allocated_spaces() == list([espacio1, espacio2]) warehouse.delete_space(espacio2) assert warehouse.list_allocated_spaces() == list([espacio1])
def test_space_to_dict(): data = { "reference": "espacio-1", "max_volume": 100, "max_weight": 100, "productos": [{ "sku": "sku-001", "description": "articulo de prueba", "volume_unit": 1, "weight_unit": 0.1, "qty": 5 }, { "sku": "sku-002", "description": "articulo de prueba 2", "volume_unit": 0.5, "weight_unit": 0.05, "qty": 10 }] } wh = Warehouse("Bodega-1") space = Space("espacio-1", 100, 100) wh.add_space(space) orderline = OrderLine("sku-001", "articulo de prueba", 1, 0.1, 5, "o-l-1") orderline2 = OrderLine("sku-002", "articulo de prueba 2", 0.5, 0.05, 10, "o-l-2") allocate(orderline, wh.get_space('espacio-1')) allocate(orderline2, wh.get_space('espacio-1')) assert data == wh.list_allocated_spaces()[0].to_dict()