def test_humanize_price_free(self): FREE = 'Free' self.assertEqual(humanize_price(0, None, 'CAD'), FREE) self.assertEqual(humanize_price(0.00, None, 'CAD'), FREE) self.assertEqual(humanize_price('0', None, 'CAD'), FREE) self.assertEqual(humanize_price('0.00', None, 'CAD'), FREE) self.assertEqual(humanize_price('0.00', 5.00, 'CAD'), 'Free-5CAD')
def test_humanize_price_single(self): self.assertEqual(humanize_price(1, None, 'CAD'), '1CAD') self.assertEqual(humanize_price('1.50', None, 'CAD'), '1.50CAD')
def test_humanize_price_range(self): self.assertEqual(humanize_price(1, 2, 'CAD'), '1-2CAD') self.assertEqual(humanize_price(2.5, 3.0, 'CAD'), '2.50-3.00CAD') self.assertEqual(humanize_price(2.5000, 3.1000, 'CAD'), '2.50-3.10CAD') # As strings self.assertEqual(humanize_price('2.5', '3.1', 'CAD'), '2.50-3.10CAD')
def test_humanize_price_none(self): out = humanize_price(None, None, 'CAD') self.assertEqual(out, '')