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
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)
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)
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)
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)