Пример #1
0
class MaxSizeCheckTest(FontTestCase):
    def setUp(self):
        super().setUp()
        self.check = MaxSizeCheck()

    def perform_check(self, target, flags):
        unit = self.get_unit()
        unit.flags = flags
        unit.target = target
        unit.state = STATE_TRANSLATED
        return self.check.check_target(["source"], [target], unit)

    def test_good(self):
        self.assertFalse(self.perform_check("short", "max-size:500"))
        self.assertEqual(self.check.last_font, "sans")

    def test_bad_long(self):
        self.assertTrue(self.perform_check("long" * 50, "max-size:500"))
        self.assertEqual(self.check.last_font, "sans")

    def test_bad_multiline(self):
        self.assertTrue(self.perform_check("long " * 50, "max-size:500"))
        self.assertEqual(self.check.last_font, "sans")

    def test_good_multiline(self):
        self.assertFalse(self.perform_check("long " * 50, "max-size:500:50"))
        self.assertEqual(self.check.last_font, "sans")

    def add_font_group(self):
        font = self.add_font()
        return FontGroup.objects.create(name="droid",
                                        font=font,
                                        project=self.project)

    def test_custom_font(self):
        self.add_font_group()
        self.assertFalse(
            self.perform_check("short", "max-size:500,font-family:droid"))
        self.assertEqual(self.check.last_font, "Droid Sans Fallback Regular")

    def test_custom_font_override(self):
        group = self.add_font_group()
        FontOverride.objects.create(group=group,
                                    language=self.get_translation().language,
                                    font=group.font)
        self.assertFalse(
            self.perform_check("short", "max-size:500,font-family:droid"))
        self.assertEqual(self.check.last_font, "Droid Sans Fallback Regular")
Пример #2
0
 def setUp(self):
     super(MaxSizeCheckTest, self).setUp()
     self.check = MaxSizeCheck()
Пример #3
0
 def setUp(self):
     super().setUp()
     self.check = MaxSizeCheck()