def test_is_valid_coin__should_assign_value_when_coin_is_valid(): valid_coin = {'weight': QUARTER['weight'], 'diameter': QUARTER['diameter']} actual = is_valid_coin(valid_coin) assert actual is True assert valid_coin['value'] == 0.25
def controller(selection, inserted_coins): product_service = ProductService(None) if not product_service.is_product_available(selection): return {'message': 'Product is unavailable!'}, False valid_coins = [ valid_coin for valid_coin in inserted_coins if coin_service.is_valid_coin(valid_coin) ] amount = coin_service.count_funds(valid_coins) cost = product_service.get_product_cost(selection) if not coin_service.has_sufficient_funds(cost, amount): return {'message': 'Insufficient funds supplied!'}, False return {'message': 'Thank you!'}, True
def test_is_valid_coin__should_return_false_when_invalid_diameter_coin_supplied( ): invalid_coin = {'diameter': 42.76, 'weight': QUARTER['weight']} actual = is_valid_coin(invalid_coin) assert actual is False
def test_is_valid_coin__should_return_false_when_invalid_weight_coin_supplied( ): invalid_coin = {'weight': 56.99} actual = is_valid_coin(invalid_coin) assert actual is False
def test_is_valid_coin__should_return_true_when_dollar_supplied(): actual = is_valid_coin(DOLLAR) assert actual is True
def test_is_valid_coin__should_return_true_when_dime_supplied(): actual = is_valid_coin(DIME) assert actual is True
def test_is_valid_coin__should_return_true_when_nickel_supplied(): actual = is_valid_coin(NICKEL) assert actual is True
def test_is_valid_coin__should_return_true_when_quarter_supplied(): actual = is_valid_coin(QUARTER) assert actual is True