@@ -124,6 +124,47 @@ def test_provider_get_requests_authored_by_user(
124124 assert set (r .id for r in api .get_requests_authored_by_user (user )) == set (expected )
125125
126126
127+ @pytest .mark .parametrize (
128+ "output_checker, expected" ,
129+ [
130+ # A non-output checker never sees outstanding requests
131+ (False , []),
132+ # An output checker only sees outstanding requests that
133+ # they did not author
134+ (True , ["r1" ]),
135+ ],
136+ )
137+ def test_provider_get_outstanding_requests_for_review (output_checker , expected , api ):
138+ user = User (1 , "test" , ["workspace" ], output_checker )
139+ other_user = User (1 , "other" , ["workspace" ], False )
140+ # request created by another user, status submitted
141+ factories .create_release_request (
142+ "workspace" , other_user , id = "r1" , status = Status .SUBMITTED
143+ )
144+
145+ # requests not visible to output checker
146+ # status submitted, but authored by output checker
147+ factories .create_release_request (
148+ "workspace" , user , id = "r2" , status = Status .SUBMITTED
149+ )
150+ # requests authored by other users, status other than pending
151+ for i , status in enumerate (
152+ [
153+ Status .PENDING ,
154+ Status .WITHDRAWN ,
155+ Status .APPROVED ,
156+ Status .REJECTED ,
157+ Status .RELEASED ,
158+ ]
159+ ):
160+ ws = f"workspace{ i } "
161+ factories .create_release_request (ws , User (1 , f"test_{ i } " , [ws ]), status = status )
162+
163+ assert set (r .id for r in api .get_outstanding_requests_for_review (user )) == set (
164+ expected
165+ )
166+
167+
127168def test_provider_get_current_request_for_user (api ):
128169 workspace = factories .create_workspace ("workspace" )
129170 user = User (1 , "testuser" , ["workspace" ], False )
@@ -276,6 +317,15 @@ def test_add_file_to_request_states(status, success, api):
276317 assert not release_request .abspath (path ).exists ()
277318
278319
320+ def test_request_release_invalid_state ():
321+ factories .create_workspace ("workspace" )
322+ with pytest .raises (AttributeError ):
323+ factories .create_release_request (
324+ "workspace" ,
325+ status = "unknown" ,
326+ )
327+
328+
279329def setup_empty_release_request ():
280330 author = User (1 , "author" , ["workspace" ], False )
281331 path = Path ("path/file.txt" )
0 commit comments