def test_defaults(self, an_addon): """Using no optional parameters should invoke defaults.""" a = an_addon a1 = Addon(a.product, a.sku, a.name, a.cost) a2 = Addon(a.product, a.sku, a.name, a.cost, "", 0, 0) assert a1 == a2
def test_get_addons_when_product_not_created_and_addon_created( product_manager, addon_data, a_blank_product): addons = product_manager.create_addon(**addon_data).get_addons() id_ = product_manager.get_product().id_ expected = Addon(a_blank_product, id_, **addon_data).addons assert addons == expected
def test_get_product_when_product_and_addon_created(product_manager, product_data, addon_data): product = product_manager\ .create_product(**product_data)\ .create_addon(**addon_data)\ .get_product() p_id = product.product.id_ a_id = product.id_ expected = Addon(Product(id_=p_id, **product_data), id_=a_id, **addon_data) assert product == expected
def test_get_addon_when_product_not_created_and_addon_created( product_manager, addon_data, a_blank_product): addon = product_manager\ .create_addon(**addon_data)\ .get_addon() id_ = product_manager.get_product().id_ expected = Addon(a_blank_product, id_, **addon_data) assert addon == expected addon = product_manager.get_addon(id_) assert addon == expected addon = product_manager.get_addon('RandomID') assert addon == None
def test_get_addon_when_product_created_and_addon_created( product_manager, product_data, addon_data): addon = product_manager\ .create_product(**product_data)\ .create_addon(**addon_data)\ .get_addon() p_id = product_manager.get_product().product.id_ a_id = product_manager.get_product().id_ expected = Addon(Product(p_id, **product_data), a_id, **addon_data) assert addon == expected addon = product_manager.get_addon(a_id) assert addon == expected addon = product_manager.get_addon('RandomID') assert addon == None
def test_new_addon_raises_ValueError(self, a_product, invalid_value_product_data): """Addon() should raise an exception with invalid param.""" with pytest.raises(ValueError): Addon(a_product, **invalid_value_product_data)
def an_addon(a_product): """Return some simple addon.""" return Addon(a_product, 325, "BV2", "Bevel Finish", 3.49, "2-inch")