File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: (C) ColdFront Authors
2
+ #
3
+ # SPDX-License-Identifier: AGPL-3.0-or-later
4
+
5
+ import logging
6
+
7
+ from django .test import TestCase
8
+
9
+ logging .disable (logging .CRITICAL )
10
+
11
+
12
+ class PortalViewBaseTest (TestCase ):
13
+ """Base class for portal view tests."""
14
+
15
+ @classmethod
16
+ def setUpTestData (cls ):
17
+ """Test Data setup for all portal view tests."""
18
+ pass
19
+
20
+
21
+ class CenterSummaryViewTest (PortalViewBaseTest ):
22
+ """Tests for center summary view"""
23
+
24
+ @classmethod
25
+ def setUpTestData (cls ):
26
+ """Set up users and project for testing"""
27
+ cls .url = "/center-summary"
28
+ super (PortalViewBaseTest , cls ).setUpTestData ()
29
+
30
+ def test_centersummary_renders (self ):
31
+ response = self .client .get (self .url )
32
+ self .assertEqual (response .status_code , 200 )
33
+ self .assertContains (response , "Active Allocations and Users" )
34
+ self .assertContains (response , "Resources and Allocations Summary" )
35
+ self .assertNotContains (response , "We're having a bit of system trouble at the moment. Please check back soon!" )
Original file line number Diff line number Diff line change 7
7
8
8
from django .conf import settings
9
9
from django .contrib .humanize .templatetags .humanize import intcomma
10
- from django .db .models import Count , Q , Sum
10
+ from django .db .models import Count , FloatField , Q , Sum
11
+ from django .db .models .functions import Cast
11
12
from django .shortcuts import render
12
13
from django .views .decorators .cache import cache_page
13
14
@@ -137,7 +138,9 @@ def center_summary(request):
137
138
138
139
# Grants Card
139
140
total_grants_by_agency_sum = list (
140
- Grant .objects .values ("funding_agency__name" ).annotate (total_amount = Sum ("total_amount_awarded" ))
141
+ Grant .objects .values ("funding_agency__name" ).annotate (
142
+ total_amount = Sum (Cast ("total_amount_awarded" , FloatField ()))
143
+ )
141
144
)
142
145
143
146
total_grants_by_agency_count = list (
You can’t perform that action at this time.
0 commit comments