@@ -752,16 +752,16 @@ def test_private_evaluation(self):
752
752
class TestResultsTextanswerVisibility (WebTest ):
753
753
754
754
fixtures = ["minimal_test_data_results" ]
755
- general_textanswers = [
755
+ general_textanswers = {
756
756
".general_orig_published." ,
757
757
".general_orig_deleted." ,
758
758
".general_changed_published." ,
759
759
".general_orig_published_changed." ,
760
760
".general_additional_orig_published." ,
761
761
".general_additional_orig_deleted." ,
762
- ]
762
+ }
763
763
764
- contributor_textanswers = [
764
+ contributor_textanswers = {
765
765
".contributor_orig_published." ,
766
766
".contributor_orig_private." ,
767
767
".responsible_contributor_orig_published." ,
@@ -772,13 +772,27 @@ class TestResultsTextanswerVisibility(WebTest):
772
772
".responsible_contributor_orig_unreviewed." ,
773
773
".responsible_contributor_additional_orig_published." ,
774
774
".responsible_contributor_additional_orig_deleted." ,
775
- ]
775
+ }
776
776
777
- standard_general_textanswers = [ # subset of general_textanswers
777
+ standard_general_textanswers = {
778
778
".general_orig_published." ,
779
779
".general_changed_published." ,
780
780
".general_additional_orig_published." ,
781
- ]
781
+ }
782
+
783
+ # subset of textanswers. These are never shown in results page
784
+ general_textanswers_never_shown = {
785
+ ".general_orig_deleted." ,
786
+ ".general_orig_published_changed." ,
787
+ ".general_additional_orig_deleted." ,
788
+ }
789
+ contributor_textanswers_never_shown = {
790
+ ".responsible_contributor_orig_deleted." ,
791
+ ".responsible_contributor_orig_published_changed." ,
792
+ ".responsible_contributor_orig_unreviewed." ,
793
+ ".responsible_contributor_additional_orig_deleted." ,
794
+ }
795
+ all_textanswers = general_textanswers | contributor_textanswers
782
796
783
797
@classmethod
784
798
def setUpTestData (cls ):
@@ -791,9 +805,8 @@ def check_with_view(
791
805
expected_visible_textanswers ,
792
806
general = ViewGeneralResults ,
793
807
contributor = ViewContributorResults ,
794
- all_textanswers = general_textanswers + contributor_textanswers ,
795
808
):
796
- textanswers_not_in = list ( set ( all_textanswers ) - set (expected_visible_textanswers ) )
809
+ expected_not_visible_textanswers = self . all_textanswers - set (expected_visible_textanswers )
797
810
for general_view , contributor_view in product (general , contributor ):
798
811
page = self .app .get (
799
812
f"/results/semester/1/evaluation/1?view_general_results={ general_view .value } &view_contributor_results={ contributor_view .value } " ,
@@ -802,24 +815,21 @@ def check_with_view(
802
815
803
816
for answer in expected_visible_textanswers :
804
817
self .assertIn (answer , page )
805
- for answer in textanswers_not_in :
818
+ for answer in (
819
+ expected_not_visible_textanswers
820
+ | self .general_textanswers_never_shown
821
+ | self .contributor_textanswers_never_shown
822
+ ):
806
823
self .assertNotIn (answer , page )
807
824
808
825
def test_manager (self ):
809
826
user = self .manager
810
827
self .check_with_view (user , [])
811
- with run_in_staff_mode (self ): # in staff mode, the manager can see everything except deleted or changed
812
- visible_contributor_textanswers = [
813
- ".contributor_orig_published." ,
814
- ".contributor_orig_private." ,
815
- ".responsible_contributor_orig_published." ,
816
- ".responsible_contributor_changed_published." ,
817
- ".responsible_contributor_orig_private." ,
818
- ".responsible_contributor_additional_orig_published." ,
819
- ]
828
+ with run_in_staff_mode (self ): # in staff mode, the manager can see every possible answer
829
+ visible_contributor_textanswers = self .contributor_textanswers - self .contributor_textanswers_never_shown
820
830
self .check_with_view (
821
831
user ,
822
- self .standard_general_textanswers + visible_contributor_textanswers ,
832
+ self .standard_general_textanswers | visible_contributor_textanswers ,
823
833
[ViewGeneralResults .FULL ],
824
834
[ViewContributorResults .FULL ],
825
835
)
@@ -841,16 +851,16 @@ def test_responsible(self):
841
851
842
852
def test_responsible_contributor (self ):
843
853
844
- visible_contributor_textanswers = [
854
+ visible_contributor_textanswers = {
845
855
".responsible_contributor_orig_published." ,
846
856
".responsible_contributor_changed_published." ,
847
857
".responsible_contributor_orig_private." ,
848
858
".responsible_contributor_additional_orig_published." ,
849
- ]
859
+ }
850
860
self .check_with_view (user , [], [ViewGeneralResults .RATINGS ], [ViewContributorResults .RATINGS ])
851
861
self .check_with_view (
852
862
user ,
853
- self .standard_general_textanswers + visible_contributor_textanswers ,
863
+ self .standard_general_textanswers | visible_contributor_textanswers ,
854
864
[ViewGeneralResults .FULL ],
855
865
[ViewContributorResults .FULL , ViewContributorResults .PERSONAL ],
856
866
)
@@ -862,7 +872,7 @@ def test_contributor_general_textanswers(self):
862
872
863
873
def test_contributor (self ):
864
874
865
- visible_contributor_textanswers = [ ".contributor_orig_published." , ".contributor_orig_private." ]
875
+ visible_contributor_textanswers = { ".contributor_orig_published." , ".contributor_orig_private." }
866
876
self .check_with_view (user , [], contributor = [ViewContributorResults .RATINGS ])
867
877
self .check_with_view (
868
878
user ,
0 commit comments