-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2160 internal user can view access requests #2469
2160 internal user can view access requests #2469
Conversation
18ab093
to
80ef128
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
assert response.status_code == 200 | ||
response_items_1 = response.json().get('items') | ||
assert response_items_1[0].get('user__first_name') == "Jane" | ||
# Test with a type filter that doesn't exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover comment? This test looks like it's checking the name filter
assert response.status_code == 200 | ||
response_data = response.json() | ||
assert len(response_data) == 2 | ||
# assert one of the approved admin user operators is in the response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert "one is in the response" as in we're checking one of the two as a sample? Or we actually only expect one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only wanted to test one of them as a sample.
== approved_admin_user_operator_to_check.user.bceid_business_name | ||
) | ||
assert ( | ||
approved_admin_user_operator_in_response["operator__legal_name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we check them one by one like this, it's possible there could be an extra value in there that we don't want and this test isn't catching. We could check that the whole object == expected object, or that the keys match what we expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test to make sure we get the expected keys.
operator__status=Operator.Statuses.DECLINED | ||
) | ||
# Subquery to check if an approved admin user exists for the operator | ||
approved_admin_operator_exists = UserOperator.objects.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cool, nice and readable
@@ -14,6 +15,11 @@ def handle_exception(error: Exception) -> Tuple[Literal[400, 401, 403, 404, 422] | |||
""" | |||
This function handles exceptions for BCEIRS. Returns a 4xx status. | |||
""" | |||
if DEBUG == "True": | |||
# Print the error in the console for easier debugging | |||
print("---------------------------------------------ERROR START-----------------------------------------------") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
) | ||
) | ||
|
||
# Add approved admin user for the approved operator (to prevent showing pending user operators for this operator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably more in the loop about this than me, but I thought the plan for reg2 was to show all the user operators in the table regardless of if there's already an admin or who approved them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with Andrea and Zoey, but I forgot to document it in this ticket. Sorry for that. Here’s the conversation: #2059 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks. Internal users don't get to approve/deny after the first admin, but are they supposed to get to view everyone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe they prefer to have a minimal number of requests in this table. From what I understand, seeing a record in the table without being able to change it might be annoying for them. Calling @andrea-williams to take radical decisions lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm overruling a comment that one SME said (that I believe was just casual and not something they were committing to). IMO it doesn't make sense to show ALL industry admins in that grid when internal users are only expected to action some of them. Internal users can view all users for a specific operator and view the admins from there if they need to.
Boom. Radical Decision made.
# make sure only irc user can access this | ||
industry_user = baker.make_recipe('utils.industry_operator_user') | ||
with pytest.raises(Exception, match=UNAUTHORIZED_MESSAGE): | ||
UserOperatorServiceV2.list_user_operators_v2( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a long test, could move some parts (e.g. testing for exceptions) into their own tests
assert user_operators_with_admin_access_status.filter(status=UserOperator.Statuses.APPROVED).count() == 5 | ||
|
||
# Check sorting | ||
filters_3 = filters_2.model_copy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
|
||
it("renders UserOperatorsPage with the note on top of the page", async () => { | ||
getUserOperatorsPageData.mockReturnValueOnce({ | ||
data: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add a third test that does have data (there's already in-depth testing of the grid in the grid test, so the one here could be super simple and just check number of rows or something to make sure the page does correctly handle a non-empty data array)
def list_user_operators_v2( | ||
request: HttpRequest, | ||
filters: UserOperatorFilterSchema = Query(...), | ||
sort_field: Optional[str] = "created_at", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created_at isn't one of the grid columns, does that matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, created_at
serves as the default value for sorting when users do not specify their own sorting preferences.(It's used for the query)
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
…tier Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
Signed-off-by: SeSo <[email protected]>
9c23643
to
5f1c36c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤸
ISSUE 2160
NOTE:
TEST:
Log in as an internal user. Click the Operator Administrators and Access Requests tile to view the data grid.