Coverage for CIResults/tests/test_metrics_views.py: 100%
43 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-19 09:20 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-19 09:20 +0000
1from datetime import timedelta
3from django.conf import settings
4from django.test import TestCase
5from django.utils import timezone
6from django.urls import reverse
8from CIResults.tests.test_views import UserFiltrableViewMixin
9from CIResults.models import BugTracker, Issue
12# HACK: Massively speed up the login primitive. We don't care about security in tests
13settings.PASSWORD_HASHERS = ('django.contrib.auth.hashers.MD5PasswordHasher', )
16class ApiMetricsTests(TestCase):
17 # TODO: Re-visit this test when we have a good fixture!
18 fixtures = ['CIResults/fixtures/RunConfigResults_commit_to_db']
20 def test_get(self):
21 response = self.client.get("/api/metrics")
22 self.assertEqual(response.status_code, 200)
23 self.assertContains(response,
24 '{"issues": 0, "machine": 1, "suppressed_tests": 1, '
25 '"suppressed_machines": 1, "tests": 1, "unknown_failures": 0, "version": 1}')
28class MetricsIssuesTests(UserFiltrableViewMixin, TestCase):
29 reverse_name = "CIResults-metrics-issues"
30 query = "expected = FALSE"
32 def setUp(self):
33 Issue.objects.create(expected=False)
34 # TODO: add a fixture with more variety
37class MetricsBugsTests(UserFiltrableViewMixin, TestCase):
38 reverse_name = "CIResults-metrics-bugs"
39 query = "status = 'open'"
41 def setUp(self):
42 # Create a bugtracker with components_followed_since set in order to
43 # enable the testing of the view
44 BugTracker.objects.create(name='bt', public=True,
45 components_followed_since=timezone.now()-timedelta(days=180))
47 # TODO: add a fixture for bugs and comments
50class MetricsCommentsTests(UserFiltrableViewMixin, TestCase):
51 reverse_name = "CIResults-metrics-comments"
52 query = "creator_is_developer = TRUE"
54 def setUp(self):
55 MetricsBugsTests().setUp()
58class MetricsOpenBugsTests(TestCase):
59 def test_view_is_redirecting(self):
60 response = self.client.get(reverse('CIResults-metrics-open-bugs'))
61 self.assertEqual(response.status_code, 302)
62 self.assertEqual(response.url, reverse('CIResults-bug-open-list'))
65class MetricsPassratePerRunconfigTests(UserFiltrableViewMixin, TestCase):
66 reverse_name = "CIResults-metrics-passrate-per-runconfig"
67 query = "test_name = 'test'"
70class MetricsPassratePerTestTests(UserFiltrableViewMixin, TestCase):
71 reverse_name = "CIResults-metrics-passrate-per-test"
72 query = "test_name = 'test'"
75class MetricsRunTimeTests(UserFiltrableViewMixin, TestCase):
76 reverse_name = "CIResults-metrics-runtime"
77 query = "machine_name = 'machine'"