2828from boac .models .peer_advising_department import PeerAdvisingDepartment
2929
3030ce3_navcal_peer_advisor_uid = '1133400'
31+ ce3_pam_advisor_uid = '2525'
32+ ce3_non_pam_advisor_uid = '5405613'
33+ coe_mech_peer_advisor_uid = '1913062'
34+ eop_peer_advisor_uid = '1563405'
3135
3236
3337class TestPeerAdvisingNoteSearch :
@@ -49,13 +53,108 @@ def test_peer_advising_search_with_missing_input_no_options(self, client, fake_a
4953 navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
5054 _api_search (client , ' \t ' , peer_advising_department_id = navcal_department .id , expected_status_code = 400 )
5155
52- def test_peer_advising_search_includes_notes_if_requested (self , client , fake_auth ):
56+ def test_peer_advising_search_notes_no_notes (self , client , fake_auth ):
5357 """Does not include any notes if the notes do not exist."""
5458 fake_auth .login (ce3_navcal_peer_advisor_uid )
5559 navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
60+ api_json = _api_search (client , 'Anastasia' , peer_advising_department_id = navcal_department .id )
61+ self ._assert (api_json , note_count = 0 , student_count = 0 )
62+
63+ def test_peer_advising_search_notes_no_match (
64+ self ,
65+ client ,
66+ fake_auth ,
67+ mock_navcal_peer_advising_note , # noqa: ARG002
68+ mock_navcal_peer_advising_note_with_comments , # noqa: ARG002
69+ ):
70+ """Does not include any notes if none match the search query."""
71+ fake_auth .login (ce3_navcal_peer_advisor_uid )
72+ navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
5673 api_json = _api_search (client , 'Brigitte' , peer_advising_department_id = navcal_department .id )
5774 self ._assert (api_json , note_count = 0 , student_count = 0 )
5875
76+ def test_peer_advising_search_includes_peer_notes (
77+ self ,
78+ client ,
79+ fake_auth ,
80+ mock_navcal_peer_advising_note , # noqa: ARG002
81+ mock_navcal_peer_advising_note_with_comments , # noqa: ARG002
82+ ):
83+ """Includes notes created by other peer advisors in the same department."""
84+ fake_auth .login (ce3_navcal_peer_advisor_uid )
85+ navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
86+ api_json = _api_search (client , 'Anastasia' , peer_advising_department_id = navcal_department .id )
87+ self ._assert (api_json , note_count = 1 , student_count = 0 )
88+
89+ api_json = _api_search (client , 'a comment' , peer_advising_department_id = navcal_department .id )
90+ self ._assert (api_json , note_count = 1 , student_count = 0 )
91+
92+ def test_peer_advising_search_includes_pam_notes (self , client , fake_auth , mock_navcal_peer_advising_manager_note ): # noqa: ARG002
93+ """Includes notes created by a Peer Advisor Manager in the same department."""
94+ fake_auth .login (ce3_navcal_peer_advisor_uid )
95+ navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
96+ api_json = _api_search (client , 'daisy' , peer_advising_department_id = navcal_department .id )
97+ self ._assert (api_json , note_count = 1 , student_count = 0 )
98+
99+ def test_search_excludes_foreign_dept_peer_notes (
100+ self ,
101+ client ,
102+ fake_auth ,
103+ mock_navcal_peer_advising_note , # noqa: ARG002
104+ mock_navcal_peer_advising_note_with_comments , # noqa: ARG002
105+ ):
106+ """Does not include notes or comments created by peer advisors outside the department."""
107+ fake_auth .login (eop_peer_advisor_uid )
108+ eop_department = PeerAdvisingDepartment .get_department_by_name ('Educational Opportunity Program' )
109+ api_json = _api_search (client , 'Anastasia' , peer_advising_department_id = eop_department .id )
110+ self ._assert (api_json , note_count = 0 , student_count = 0 )
111+
112+ api_json = _api_search (client , 'comment' , peer_advising_department_id = eop_department .id )
113+ self ._assert (api_json , note_count = 0 , student_count = 0 )
114+
115+ def test_excludes_foreign_dept_pam_notes (self , client , fake_auth , mock_navcal_peer_advising_manager_note ): # noqa: ARG002
116+ """Does not include a note created by Peer Advisor Manager outside the department."""
117+ fake_auth .login (eop_peer_advisor_uid )
118+ eop_department = PeerAdvisingDepartment .get_department_by_name ('Educational Opportunity Program' )
119+ api_json = _api_search (client , 'daisy' , peer_advising_department_id = eop_department .id )
120+ self ._assert (api_json , note_count = 0 , student_count = 0 )
121+
122+ def test_search_excludes_same_dept_non_pam_note (self , client , fake_auth , mock_ce3_advising_note ): # noqa: ARG002
123+ """Does not include a peer advising note created by a non-PAM advisor in the same department."""
124+ fake_auth .login (ce3_navcal_peer_advisor_uid )
125+ navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
126+ api_json = _api_search (client , 'darling' , peer_advising_department_id = navcal_department .id )
127+ self ._assert (api_json , note_count = 0 , student_count = 0 )
128+
129+ fake_auth .login (eop_peer_advisor_uid )
130+ eop_department = PeerAdvisingDepartment .get_department_by_name ('Educational Opportunity Program' )
131+ api_json = _api_search (client , 'darling' , peer_advising_department_id = eop_department .id )
132+ self ._assert (api_json , note_count = 0 , student_count = 0 )
133+
134+ def test_search_excludes_pam_comment_foreign_dept_peer_note (
135+ self ,
136+ client ,
137+ fake_auth ,
138+ mock_navcal_peer_advising_note_with_comments , # noqa: ARG002
139+ ):
140+ """Does not include a peer advising note from a different department and commented on by Peer Advisor Manager in the same department."""
141+ fake_auth .login (coe_mech_peer_advisor_uid )
142+ mech_eng_department = PeerAdvisingDepartment .get_department_by_name ('Mechanical Engineering' )
143+ api_json = _api_search (client , 'a comment' , peer_advising_department_id = mech_eng_department .id )
144+ self ._assert (api_json , note_count = 0 , student_count = 0 )
145+
146+ def test_search_excludes_pam_comment_non_peer_note (
147+ self ,
148+ client ,
149+ fake_auth ,
150+ mock_advising_note_with_comments , # noqa: ARG002
151+ ):
152+ """Does not include a non-peer note commented on by a Peer Advisor Manager in the same department."""
153+ fake_auth .login (ce3_navcal_peer_advisor_uid )
154+ navcal_department = PeerAdvisingDepartment .get_department_by_name ('NAVCAL' )
155+ api_json = _api_search (client , 'a comment' , peer_advising_department_id = navcal_department .id )
156+ self ._assert (api_json , note_count = 0 , student_count = 0 )
157+
59158
60159def _api_search (
61160 client ,
0 commit comments