예제 #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_ordering_cost_calculates_correctly():
    oc = Costs.ordering_cost(ordering_cost=100.0,
                             demand_quantity=250,
                             order_quantity=25)
    assert oc == 100.0 * (250 / 25)
예제 #3
0
def test_ordering_cost_with_zero_order_quantity_raises():
    with pytest.raises(ValueError):
        Costs.ordering_cost(ordering_cost=1.0,
                            demand_quantity=1,
                            order_quantity=0)
예제 #4
0
def test_ordering_cost_with_negative_demand_quantity_raises():
    with pytest.raises(ValueError):
        Costs.ordering_cost(ordering_cost=1.0,
                            demand_quantity=-1,
                            order_quantity=1)
예제 #5
0
def test_ordering_cost_with_missing_demand_quantity_raises():
    with pytest.raises(ValueError):
        Costs.ordering_cost(ordering_cost=1.0,
                            demand_quantity=None,
                            order_quantity=1)