diff --git a/sate24.py b/sate24.py index 8771d0d..d91b8c9 100644 --- a/sate24.py +++ b/sate24.py @@ -35,13 +35,16 @@ def main(): return def removeProduct(products, product): - products = products.upper() - - newProducts = products.split(',') - newProducts.remove(product.upper()) - - newProducts.sort() - return ','.join(newProducts) + try: + products = products.upper() + + newProducts = products.split(',') + newProducts.remove(product.upper()) + + newProducts.sort() + return ','.join(newProducts) + except: + return products if __name__ == '__main__': main() diff --git a/test_sate24.py b/test_sate24.py index 0dac9ee..b946f16 100644 --- a/test_sate24.py +++ b/test_sate24.py @@ -19,3 +19,9 @@ def test_keyByRequestId(): def test_keyByNominalDestination(): assert sate24.keyByNominalDestination('TEST', '5000', '08180818') == 'TEST.trx.nominal:5000.destination:08180818' + +def test_removeProduct(): + assert sate24.removeProduct('XL5,XL10', 'XL5') == 'XL10' + assert sate24.removeProduct('XL5,XL10', 'XL10') == 'XL5' + assert sate24.removeProduct('XL10', 'XL10') == '' + assert sate24.removeProduct('XL5,XL10', 'XL50') == 'XL5,XL10'