5
5
from django .core .management import call_command
6
6
from django .test import TestCase
7
7
8
- from crowdsourcer .models import Question , Response
8
+ from crowdsourcer .models import MarkingSession , Question , Response
9
9
from crowdsourcer .scoring import get_section_maxes
10
10
11
11
max_section = {
@@ -161,9 +161,12 @@ class ExportNoMarksTestCase(BaseCommandTestCase):
161
161
"options.json" ,
162
162
]
163
163
164
+ def setUp (self ):
165
+ self .session = MarkingSession .objects .get (label = "Default" )
166
+
164
167
def test_max_calculation (self ):
165
168
scoring = {}
166
- get_section_maxes (scoring )
169
+ get_section_maxes (scoring , self . session )
167
170
168
171
self .assertEquals (scoring ["section_maxes" ], max_section )
169
172
self .assertEquals (scoring ["group_maxes" ], max_totals )
@@ -174,7 +177,7 @@ def test_max_calculation_with_unweighted_q(self):
174
177
Question .objects .filter (pk = 272 ).update (weighting = "unweighted" )
175
178
176
179
scoring = {}
177
- get_section_maxes (scoring )
180
+ get_section_maxes (scoring , self . session )
178
181
179
182
local_max_w = max_weighted .copy ()
180
183
local_max_w ["Buildings & Heating" ] = {
@@ -197,9 +200,7 @@ def test_max_calculation_with_unweighted_q(self):
197
200
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
198
201
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
199
202
def test_export_with_no_marks (self , write_mock ):
200
- self .call_command (
201
- "export_marks" ,
202
- )
203
+ self .call_command ("export_marks" , session = "Default" )
203
204
204
205
expected_percent = [
205
206
{
@@ -329,7 +330,7 @@ def test_max_calculation(self):
329
330
scoring = {}
330
331
expected_max_q = deepcopy (max_questions )
331
332
expected_max_q ["Buildings & Heating" ]["20" ] = 0
332
- get_section_maxes (scoring )
333
+ get_section_maxes (scoring , MarkingSession . objects . get ( label = "Default" ) )
333
334
334
335
self .assertEquals (scoring ["section_maxes" ], max_section )
335
336
self .assertEquals (scoring ["group_maxes" ], max_totals )
@@ -478,7 +479,7 @@ class ExportWithMarksTestCase(BaseCommandTestCase):
478
479
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
479
480
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
480
481
def test_export (self , write_mock ):
481
- self .call_command ("export_marks" )
482
+ self .call_command ("export_marks" , session = "Default" )
482
483
483
484
percent , raw , linear = write_mock .call_args [0 ]
484
485
self .assertEquals (raw , self .expected_raw )
@@ -491,7 +492,7 @@ def test_export(self, write_mock):
491
492
def test_export_with_unweighted_q (self , write_mock ):
492
493
Question .objects .filter (pk = 272 ).update (weighting = "unweighted" )
493
494
494
- self .call_command ("export_marks" )
495
+ self .call_command ("export_marks" , session = "Default" )
495
496
496
497
expected_percent = deepcopy (self .expected_percent )
497
498
expected_percent [0 ]["Buildings & Heating" ] = 0.17
@@ -508,7 +509,7 @@ def test_export_with_unweighted_q(self, write_mock):
508
509
def test_export_with_exceptions (self , write_mock ):
509
510
Response .objects .filter (question_id = 282 , authority_id = 2 ).delete ()
510
511
511
- self .call_command ("export_marks" )
512
+ self .call_command ("export_marks" , session = "Default" )
512
513
expected_linear = deepcopy (self .expected_linear )
513
514
514
515
expected_linear [1 ] = (
@@ -552,7 +553,7 @@ def test_export_with_score_exceptions(self, write_mock):
552
553
r .multi_option .add (161 )
553
554
r .save ()
554
555
555
- self .call_command ("export_marks" )
556
+ self .call_command ("export_marks" , session = "Default" )
556
557
expected_linear = deepcopy (self .expected_linear )
557
558
558
559
expected_linear [1 ] = (
@@ -610,7 +611,7 @@ def test_export_with_score_exceptions(self, write_mock):
610
611
expected_percent [1 ]["raw_total" ] = 0.07
611
612
expected_percent [1 ]["weighted_total" ] = 0.2
612
613
613
- self .call_command ("export_marks" )
614
+ self .call_command ("export_marks" , session = "Default" )
614
615
percent , raw , linear = write_mock .call_args [0 ]
615
616
self .assertEquals (linear , expected_linear )
616
617
self .assertEquals (raw , expected_raw )
@@ -622,7 +623,7 @@ def test_export_with_score_exceptions(self, write_mock):
622
623
def test_export_with_council_type_exceptions (self , write_mock ):
623
624
Response .objects .filter (question_id = 282 , authority_id = 2 ).delete ()
624
625
625
- self .call_command ("export_marks" )
626
+ self .call_command ("export_marks" , session = "Default" )
626
627
expected_linear = deepcopy (self .expected_linear )
627
628
628
629
expected_linear [1 ] = (
@@ -660,7 +661,7 @@ def test_export_with_council_type_exceptions(self, write_mock):
660
661
def test_export_with_council_name_exceptions (self , write_mock ):
661
662
Response .objects .filter (question_id = 282 , authority_id = 2 ).delete ()
662
663
663
- self .call_command ("export_marks" )
664
+ self .call_command ("export_marks" , session = "Default" )
664
665
expected_linear = deepcopy (self .expected_linear )
665
666
666
667
expected_linear [1 ] = (
@@ -703,7 +704,7 @@ def test_export_with_housing_exception(self, write_mock):
703
704
r .option_id = 205
704
705
r .save ()
705
706
706
- self .call_command ("export_marks" )
707
+ self .call_command ("export_marks" , session = "Default" )
707
708
708
709
expected_linear = deepcopy (self .expected_linear )
709
710
@@ -808,7 +809,7 @@ class ExportWithMarksNegativeQTestCase(BaseCommandTestCase):
808
809
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
809
810
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
810
811
def test_export (self , write_mock ):
811
- self .call_command ("export_marks" )
812
+ self .call_command ("export_marks" , session = "Default" )
812
813
813
814
percent , raw , linear = write_mock .call_args [0 ]
814
815
self .assertEquals (raw , self .expected_raw )
@@ -829,7 +830,7 @@ class ExportWithMultiMarksTestCase(BaseCommandTestCase):
829
830
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
830
831
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
831
832
def test_export (self , write_mock ):
832
- self .call_command ("export_marks" )
833
+ self .call_command ("export_marks" , session = "Default" )
833
834
834
835
expected_percent = [
835
836
{
@@ -934,7 +935,7 @@ class ExportWithMoreMarksTestCase(BaseCommandTestCase):
934
935
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
935
936
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
936
937
def test_export (self , write_mock ):
937
- self .call_command ("export_marks" )
938
+ self .call_command ("export_marks" , session = "Default" )
938
939
939
940
expected_percent = [
940
941
{
@@ -1039,7 +1040,7 @@ class ExportNoMarksCATestCase(BaseCommandTestCase):
1039
1040
1040
1041
def test_max_calculation (self ):
1041
1042
scoring = {}
1042
- get_section_maxes (scoring )
1043
+ get_section_maxes (scoring , MarkingSession . objects . get ( label = "Default" ) )
1043
1044
1044
1045
ca_max_section = {
1045
1046
** max_section ,
@@ -1092,9 +1093,7 @@ def test_max_calculation(self):
1092
1093
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
1093
1094
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
1094
1095
def test_export_with_no_marks (self , write_mock ):
1095
- self .call_command (
1096
- "export_marks" ,
1097
- )
1096
+ self .call_command ("export_marks" , session = "Default" )
1098
1097
1099
1098
expected_percent = [
1100
1099
{
@@ -1379,7 +1378,7 @@ class ExportWithMoreMarksCATestCase(BaseCommandTestCase):
1379
1378
@mock .patch ("crowdsourcer.scoring.EXCEPTIONS" , {})
1380
1379
@mock .patch ("crowdsourcer.scoring.SCORE_EXCEPTIONS" , {})
1381
1380
def test_export (self , write_mock ):
1382
- self .call_command ("export_marks" )
1381
+ self .call_command ("export_marks" , session = "Default" )
1383
1382
1384
1383
percent , raw , linear = write_mock .call_args [0 ]
1385
1384
@@ -1394,7 +1393,7 @@ def test_export_100_percent(self, write_mock):
1394
1393
Response .objects .filter (pk = 37 ).update (option_id = 196 )
1395
1394
Response .objects .get (pk = 36 ).multi_option .add (195 )
1396
1395
1397
- self .call_command ("export_marks" )
1396
+ self .call_command ("export_marks" , session = "Default" )
1398
1397
1399
1398
expected_raw = self .expected_raw .copy ()
1400
1399
expected_percent = self .expected_percent .copy ()
0 commit comments