From 3deb84a9dc6eb451798b8bdf6f3b3b5bfe09d536 Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <gua@adhisimon.org>
Date: Fri, 12 Feb 2016 13:47:14 +0700
Subject: [PATCH] exception handling on removeProduct

---
 sate24.py      | 17 ++++++++++-------
 test_sate24.py |  6 ++++++
 2 files changed, 16 insertions(+), 7 deletions(-)

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'
-- 
1.9.0