Commit 6a8ab796 authored by Michal Čihař's avatar Michal Čihař

Test all color variants for badges

Also adjusted color levels a bit to use >= instead of >.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 22a19232
......@@ -24,6 +24,7 @@ Tests for widgets.
from django.core.urlresolvers import reverse
from weblate.trans.models import Translation
from weblate.trans.tests.test_views import ViewTestCase
from weblate.trans.views.widgets import WIDGETS
......@@ -71,6 +72,25 @@ class WidgetsTest(ViewTestCase):
else:
self.assertPNG(response)
def test_view_widget_percents(self):
for translated in (0, 3, 4):
Translation.objects.update(translated=translated)
for widget in WIDGETS:
color = WIDGETS[widget].colors[0]
response = self.client.get(
reverse(
'widget-image',
kwargs={
'project': self.project.slug,
'widget': widget,
'color': color,
'extension': 'png',
}
)
)
self.assert_widget(widget, response)
def test_view_widget_image(self):
for widget in WIDGETS:
for color in WIDGETS[widget].colors:
......
......@@ -313,9 +313,9 @@ class BadgeWidget(Widget):
order = 90
def get_filename(self):
if self.percent > 90:
if self.percent >= 90:
mode = 'passing'
elif self.percent > 75:
elif self.percent >= 75:
mode = 'medium'
else:
mode = 'failing'
......@@ -350,9 +350,9 @@ class ShieldsBadgeWidget(Widget):
order = 80
def redirect(self):
if self.percent > 90:
if self.percent >= 90:
color = 'brightgreen'
elif self.percent > 75:
elif self.percent >= 75:
color = 'yellow'
else:
color = 'red'
......@@ -388,9 +388,9 @@ class SVGBadgeWidget(Widget):
font = get_font(11, False, is_base(percent_text))
percent_width = font.getsize(percent_text)[0] + 7
if self.percent > 90:
if self.percent >= 90:
color = '#4c1'
elif self.percent > 75:
elif self.percent >= 75:
color = '#dfb317'
else:
color = '#e05d44'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment