예제 #1
0
def test_trc_calculates_correctly():
    # arrange
    demand = get_demand()
    raw_costs = get_raw_costs()
    order_quantity = 100

    # act
    trc = Costs.total_relevant_cost(raw_costs=raw_costs,
                                    demand=demand,
                                    order_quantity=order_quantity)

    # assert
    ordering_cost = Costs.ordering_cost(ordering_cost=raw_costs.ordering_cost,
                                        demand_quantity=demand.quantity,
                                        order_quantity=order_quantity)
    holding_cost = Costs.holding_cost(holding_cost=raw_costs.holding_cost,
                                      order_quantity=order_quantity)

    assert trc == ordering_cost + holding_cost
예제 #2
0
def test_holding_cost_with_missing_holding_cost_raises():
    with pytest.raises(ValueError):
        Costs.holding_cost(holding_cost=None, order_quantity=1)
예제 #3
0
def test_holding_cost_calculates_correctly():
    hc = Costs.holding_cost(holding_cost=0.25, order_quantity=100)
    assert hc == 0.25 * (100 / 2)
예제 #4
0
def test_holding_cost_with_negative_order_quantity_raises():
    with pytest.raises(ValueError):
        Costs.holding_cost(holding_cost=1.0, order_quantity=-1)