def test_find_and_modify_raises_ressource_not_found_error(self, app): # Given offer1 = Offer(name='foo', type='bar') ApiHandler.save(offer1) # When with pytest.raises(ResourceNotFoundError) as e: Offer.find_and_modify({ '__SEARCH_BY__': 'name', 'name': 'fee', 'type': 'bric' }) # Then assert e.value.errors['find_and_modify'] == [ 'No ressource found with {"name": "fee"} ' ]
def test_find_and_modify_returns_modified_offer(self, app): # Given offer1 = Offer(name='foo', type='bar') ApiHandler.save(offer1) # When offer2 = Offer.find_and_modify({ '__SEARCH_BY__': 'name', 'name': 'foo', 'type': 'bric' }) # Then assert offer2.id == offer1.id assert offer2.name == offer1.name == 'foo' assert offer2.type == 'bric'