def test_change_base(self): self.assertAlmostEqual(changeBase(1, "INR", "GBP", "2010-10-25"), 0.0135508231, delta=0.1) self.assertAlmostEqual(changeBase(100000, "RON", "CHF", "2019-10-01"), 22954.6841784, delta=1) self.assertAlmostEqual(changeBase(0, "CAD", "CZK", "2010-10-18"), 0.0, delta=0) self.assertAlmostEqual(changeBase(12, "DKK", "LVL", "2012-07-14"), 1.12296834039, delta=0.1) self.assertAlmostEqual(changeBase(20, "HRK", "KRW", "2010-10-25"), 4265.97469113, delta=0.1) self.assertAlmostEqual(changeBase(15, "EUR", "HUF", "2013-10-25"), 4392.3, delta=0.1) self.assertAlmostEqual(changeBase(30, "TRY", "EUR", "2018-02-25"), 6.44122383253, delta=0.5) self.assertAlmostEqual(changeBase(13.7514, "JPY", "PLN", "2015-04-15"), 0.4366928147, delta=0.1) self.assertAlmostEqual(changeBase(0.1, "ZAR", "USD", "2017-11-22"), 0.00720399779, delta=0.1) self.assertAlmostEqual(changeBase(0.005, "NZD", "IDR", "2016-06-02"), 46.3421755494, delta=0.01)
def test_change_base(self): # these are just sample values. You have to add testcases (and edit these) for various dates. # (don't use the current date as the json would keep changing every 4 minutes) # you have to hard-code the 2nd parameter of assertEquals by calculating it manually # on a particular date and checking whether your changeBase function returns the same # value or not. self.assertTrue( changeBase(240, "CAD", "CAD", "2010-10-25") == 240.00000000000003) self.assertEquals(changeBase(100, "INR", "USD", "2018-08-13"), 1.4282225186465516) self.assertAlmostEqual(changeBase(10, "KRW", "EUR", "2016-08-03"), 12513.40, delta=0.1) self.assertAlmostEqual(changeBase(1, "SGD", "HKD", "2017-07-08"), 5.656, delta=0.01) self.assertAlmostEqual(changeBase(1, "USD", "AUD", "2010-08-10"), 1.102, delta=0.01) self.assertAlmostEqual(changeBase(1, "USD", "CAD", "2006-07-10"), 1.124, delta=0.01) self.assertEquals(changeBase(120, "EUR", "EUR", "2000-10-26"), 120.0) self.assertFalse(changeBase(140, "DKK", "TRY", "2013-08-19") == 69.078) self.assertAlmostEqual(changeBase(100, "CAD", "EUR", "2003-06-26"), 154.7, delta=0.05) self.assertAlmostEquals(changeBase(150, "EUR", "PLN", "2006-06-06"), 37.895055958365965) print("DONE")
def test_change_base(self): self.assertAlmostEqual(changeBase(1, "INR", "GBP", "2010-10-25"), 0.014,delta=0.0005) self.assertEqual(changeBase(3, "EUR", "USD", "1999-08-15"), 3.2001) self.assertAlmostEqual(changeBase(5, "INR", "GBP", "2010-10-25"), 0.01, delta = 0.1) self.assertAlmostEqual(changeBase(7, "USD", "MYR", "2015-07-15"), 26.6, delta = 0.05) self.assertEqual(changeBase(1, "EUR", "INR", "2019-03-11"), 78.547) self.assertEqual(changeBase(1.3965, "CAD", "TRY", "2017-02-11"), 3.9173) self.assertAlmostEqual(changeBase(3.1, "PLN", "JPY", "2000-02-29"), 82.09, delta= 0.001)
def test_change_base(self): self.assertAlmostEqual(changeBase(1, "GBP", "INR", "2010-10-25"), 69.732, delta = 0.001) self.assertAlmostEqual(changeBase(-1, "GBP", "INR", "2010-10-25"), -69.732, delta = 0.001) self.assertAlmostEqual(changeBase(45.234, "USD", "MYR", "2018-09-09"), 187.576, delta = 0.001) self.assertEqual(changeBase(1, "INR", "INR", "2019-01-01"), 1) self.assertEqual(changeBase(0, "INR", "USD", "2019-01-01"), 0) self.assertEqual(changeBase(1, "USD", "ABC", "2019-01-01"), "Invalid currency code") self.assertEqual(changeBase(1, "USD", "INR", "2019-01-41"), "Invalid date format")
def test_change_base(self): self.assertEqual(changeBase(201, "INR", "INR", "2016-10-25"), 201.0) self.assertAlmostEqual(changeBase(201, "INR", "INR", "2016-10-25"), 201.0, delta = 0.1) # these are just sample values. You have to add testcases (and edit these) for various dates. # (don't use the current date as the json would keep changing every 4 minutes) # you have to hard-code the 2nd parameter of assertEquals by calculating it manually # on a particular date and checking whether your changeBase function returns the same # value or not. self.assertEqual(changeBase(0, "INR", "ZAR", "2018-10-25"), 0.0) self.assertAlmostEqual(changeBase(0, "INR", "ZAR", "2018-10-25"), 0.0, delta = 0.1) self.assertEqual(changeBase(1000, "MYR", "USD", "2006-10-01"), 271.1849884) self.assertAlmostEqual(changeBase(1000, "MYR", "USD", "2006-10-01"), 271.1, delta = 0.1) self.assertEqual(changeBase(99, "RON", "USD", "2009-10-17"), 34.3274800572) self.assertAlmostEqual(changeBase(99, "RON", "USD", "2009-10-17"), 34.3, delta = 0.1) self.assertEqual(changeBase(5, "MYR", "INR", "2014-9-23"), 93.913495554) self.assertAlmostEqual(changeBase(5, "MYR", "INR", "2014-9-23"), 93.91, delta = 0.1)
def test_change_base(self): self.assertEqual(changeBase(1, "INR", "GBP", "2010-10-25"), 0.014340456298200513) self.assertEqual(changeBase(1, "INR", "CAD","2017-10-09"),0.019190359876241656 ) self.assertEqual(changeBase(100,"EUR","EUR","2017-10-09"),100.0) self.assertAlmostEqual(changeBase(100, "CAD", "GBP", "2010-10-25"),62.4553915051) self.assertAlmostEqual(changeBase(100, "EUR", "INR", "2010-10-25"),6224.0) self.assertAlmostEqual(changeBase(1, "INR", "GBP", "2010-10-25"),0.014340456298200513,delta=0.1)
def test_change_base(self): self.assertEqual(changeBase(100, "INR", "RON", "2011-10-31"), 6.358062718178886) self.assertAlmostEqual(changeBase(1, "INR", "GBP", "2009-10-25"), 0.014, delta=0.001) self.assertEqual(changeBase(100, "EUR", "EUR", "1999-01-05"), 100) self.assertEqual(changeBase(1, "EUR", "MYR", "2019-08-25"), 4.636) self.assertAlmostEqual(changeBase(1.1564, "AUD", "IDR", "2009-08-20"), 9675.08, delta=0.01) self.assertAlmostEqual(changeBase(19.4526, "USD", "EUR", "2001-09-11"), 21.6, delta=0.2) self.assertEqual(changeBase(123456, "CHF", "JPY", "2005-03-21"), 11066959.938128382)
def test_change_base(self): self.assertEqual(changeBase(1, "INR", "GBP", "2014-10-25"), 0.01018280504195388) self.assertEqual(changeBase(1, "MYR", "USD", "2018-12-22"), 0.23974962191228366) self.assertEqual(changeBase(1, "CAD", "KRW", "2019-02-28"), 851.6620130301822) self.assertAlmostEqual(changeBase(1, "CAD", "KRW", "2019-02-28"), 851.6, delta=0.1) self.assertEqual(changeBase(1, "SGD", "THB", "2017-04-25"), 24.711272247857618) self.assertEqual(changeBase(1, "JPY", "USD", "2019-09-09"), 0.009349207694263197) self.assertAlmostEqual(changeBase(1, "JPY", "USD", "2019-09-09"), 0.01, delta=0.1)
def test_change_base(self): #CornerCase1 self.assertTrue(changeBase(700, "EUR", "EUR", "2010-01-12") == 700.0) #Cornercase2 self.assertTrue(changeBase(0, "HKD", "EUR", "2015-04-15") == 0) self.assertNotAlmostEqual(changeBase(0, "HKD", "EUR", "2015-04-15"), 0.00034552, 5) self.assertAlmostEqual(changeBase(0, "HKD", "EUR", "2015-04-15"), 0.00034552, 3) self.assertEqual(changeBase(0, "HKD", "EUR", "2015-04-15"), 0) #CornerCase3 self.assertEqual(changeBase(900, "CAD", "CAD", "2015-12-09"), 900.0) self.assertTrue(changeBase(900, "CAD", "CAD", "2015-12-09") == 900) self.assertNotAlmostEqual(changeBase(100, "CAD", "CAD", "2010-01-12"), 100.005, 3) #CornerCase4 self.assertAlmostEqual(changeBase(50, "USD", "PLN", "2019-10-11"), 194.95, delta=0.1) self.assertFalse(changeBase(50, "USD", "PLN", "2019-10-11") == 224.908) #CornerCase5 self.assertFalse( changeBase(57, "HKD", "EUR", "2013-02-10") == 34.32342) self.assertAlmostEqual(changeBase(57, "HKD", "EUR", "2013-02-10"), 5.49540603, delta=0.1) #6 self.assertFalse(changeBase(1, "INR", "GBP", "2010-10-25") == 2.57) #7 self.assertAlmostEqual(changeBase(100, "EUR", "INR", "2010-01-12"), 6620.9999999, delta=0.1) #8 self.assertEqual(changeBase(1, "INR", "GBP", "2010-10-25"), 0.0143404563) self.assertAlmostEqual(changeBase(1, "INR", "GBP", "2010-10-25"), 0.0143, delta=0.1) #9 self.assertTrue( changeBase(250, "USD", "NZD", "2019-10-11") == 394.344833825) self.assertEqual(changeBase(250, "USD", "NZD", "2019-10-11"), 394.344833825)
def test_change_base(self): self.assertAlmostEqual(changeBase(100, "PLN", "PHP", "2018-08-22"), 1448.541603418883) self.assertAlmostEqual(changeBase(10, "EUR", "PHP", "2018-08-06"), 610.36) self.assertAlmostEqual(changeBase(1000, "PLN", "EUR", "2018-04-11"), 238.5780746749374) self.assertAlmostEqual(changeBase(5, "INR", "INR", "2018-08-10"), 5.0)
def test_change_base(self): self.assertEqual( changeBase(1, "INR", "GBP", "2010-10-25"), 0.014340456298200513 ) #changing base from weaker currency(greater value) to stronger currency(lesser value) self.assertAlmostEqual(changeBase(250, "INR", "GBP", "2010-10-25"), 3.585114074550128, delta=0.1) self.assertEqual( changeBase(250, "RUB", "IDR", "2018-10-25"), 57903.51668169522 ) #Changing base from stronger currency(lesser value) to weaker currency(greater value) self.assertAlmostEqual(changeBase(100, "RUB", "IDR", "2018-10-25"), 23161.406672678087, delta=0.1) self.assertAlmostEqual(changeBase(250, "EUR", "CNY", "2017-06-25"), 1910.325, delta=0.1) #when current currency is EURO self.assertAlmostEqual(changeBase(100, "EUR", "CNY", "2017-06-25"), 764.13, delta=0.1) self.assertAlmostEqual(changeBase(250, "NOK", "EUR", "2015-12-05"), 27.0284880264, delta=0.1) #when desired currency is EURO self.assertAlmostEqual(changeBase(100, "NOK", "EUR", "2015-12-05"), 10.81139521, delta=0.1) self.assertEqual( changeBase(250, "EUR", "EUR", "2017-06-25"), 250.0) #when both current currency and desired currency is EURO self.assertEqual(changeBase(100, "EUR", "EUR", "2018-10-25"), 100) self.assertEqual( changeBase(250, "DKK", "CND", "2017-06-25"), "Wrong currency entered") #when wrong desired currency is entered self.assertAlmostEqual( changeBase(100, "RUP", "IDR", "2018-10-25"), "Wrong currency entered", delta=0.1) #when wrong current currency is entered self.assertEqual(changeBase(0, "DKK", "IDR", "2019-01-01"), 0) #when amount=0 self.assertAlmostEqual(changeBase(0, "DKK", "IDR", "2019-01-01"), 0) self.assertEqual(changeBase(250, "JPY", "JPY", "2019-04-28"), 250) #when currency and desired currency are the same self.assertAlmostEqual(changeBase(100, "JPY", "JPY", "2019-04-28"), 100) self.assertAlmostEqual( changeBase(100, "JPY", "JPY", "2019-04-28"), 100) #when currency and desired currency are the same