from decimal import Decimal from django.test import SimpleTestCase from utils.assets import get_css from utils.colors import gamma_correction, get_percieved_lightness, is_bright_color from utils.markdown import md_to_html from utils.money import format_money class ColorsTests(SimpleTestCase): def test_gamma_correction(self): r, g, b = 10, 120, 255 self.assertEqual(gamma_correction(r), 0.003035269835488375) self.assertEqual(gamma_correction(g), 0.18782077230067787) self.assertEqual(gamma_correction(b), 1) def test_percieved_lightness(self): self.assertLess(get_percieved_lightness((10, 120, 255)), 53) self.assertGreater(get_percieved_lightness((10, 120, 255)), 52) def test_is_bright_color(self): self.assertFalse(is_bright_color("#123321")) self.assertTrue(is_bright_color("#58b783")) self.assertTrue(is_bright_color("#af6bce")) class MarkdownTests(SimpleTestCase): def test_basic_markdown(self): self.assertHTMLEqual( md_to_html("**test** *it*"), "
test it
" ) def test_nb_md(self): self.assertHTMLEqual( md_to_html("This\nis\nTest"), "This
is
Test