Exemple #1
0
 def test_rate_from_str_unknown_char_fails(self):
     with self.assertRaises(ValueError):
         rate_from_str('unknown', 30)
Exemple #2
0
 def test_rate_from_str_multiple_of(self):
     self.assertEqual(rate_from_str('1x', 23.976), 23.976)
     self.assertEqual(rate_from_str('1.1x', 23.976), 23.976 * 1.1)
     self.assertEqual(rate_from_str('0.9x', 23.976), 23.976 * 0.9)
Exemple #3
0
 def test_rate_from_str_less_than_equal_to_zero_fails(self):
     with self.assertRaises(ValueError):
         rate_from_str('0', 30)
     with self.assertRaises(ValueError):
         rate_from_str('-1', 30)
Exemple #4
0
 def test_rate_from_str_fractional(self):
     self.assertEqual(rate_from_str('24000/1001', 30), 24000 * 1.0 / 1001)
Exemple #5
0
 def test_rate_from_str_non_rational_fraction(self):
     self.assertEqual(rate_from_str('24.0/1001', 30), 24 * 1.0 / 1001)
     self.assertEqual(rate_from_str('24/1.001', 30), 24 * 1.0 / 1.001)
     self.assertEqual(rate_from_str('24.0/1.001', 30), 24 * 1.0 / 1.001)
Exemple #6
0
 def test_rate_from_str_is_none(self):
     self.assertEqual(rate_from_str(None, 30), 30)
Exemple #7
0
 def test_rate_from_str_integer_or_float(self):
     self.assertEqual(rate_from_str('24', 30), 24)
     self.assertEqual(rate_from_str('25.0', 30), 25)
Exemple #8
0
 def test_rate_from_str_less_than_equal_to_zero_fails(self):
     with self.assertRaises(ValueError):
         rate_from_str('0', 30)
     with self.assertRaises(ValueError):
         rate_from_str('-1', 30)
Exemple #9
0
 def test_rate_from_str_unknown_char_fails(self):
     with self.assertRaises(ValueError):
         rate_from_str('unknown', 30)
Exemple #10
0
 def test_rate_from_str_multiple_of(self):
     self.assertEqual(rate_from_str('1x', 23.976), 23.976)
     self.assertEqual(rate_from_str('1.1x', 23.976), 23.976*1.1)
     self.assertEqual(rate_from_str('0.9x', 23.976), 23.976*0.9)
Exemple #11
0
 def test_rate_from_str_non_rational_fraction(self):
     self.assertEqual(rate_from_str('24.0/1001', 30), 24*1.0/1001)
     self.assertEqual(rate_from_str('24/1.001', 30), 24*1.0/1.001)
     self.assertEqual(rate_from_str('24.0/1.001', 30), 24*1.0/1.001)
Exemple #12
0
 def test_rate_from_str_fractional(self):
     self.assertEqual(rate_from_str('24000/1001', 30), 24000*1.0/1001)
Exemple #13
0
 def test_rate_from_str_integer_or_float(self):
     self.assertEqual(rate_from_str('24', 30), 24)
     self.assertEqual(rate_from_str('25.0', 30), 25)
Exemple #14
0
 def test_rate_from_str_is_none(self):
     self.assertEqual(rate_from_str(None, 30), 30)