@pytest.mark.django_db
def test_ssorequestaccessview_post_with_complete_data(admin_client, admin_user, groups_with_info, team_leaders):
    group = groups_with_info[0]
    team_leader = team_leaders[0]
    with patch('users.views.notify_team_leader_of_pending_access_request', autospec=True) as mocked_method:
        response = admin_client.post(reverse('sso:request_access'), data={'self_assigned_group': group.id, 'team_leader': team_leader.id})
    success_url = reverse('sso:request_access_success')
    assert (response.url == success_url)
    profile = admin_user.userprofile
    assert (profile.self_assigned_group_id == group.id)
    assert (profile.team_leader_id == team_leader.id)
    assert (profile.assignment_status == UserProfile.STATUS_AWAITING_APPROVAL)
    expected_call_args = dict(request=response.wsgi_request, team_leader_email=team_leader.email, team_leader_name=team_leader.first_name, user_id=admin_user.id, user_name=admin_user.get_full_name(), user_email=admin_user.email, user_role=group.info.name_singular)
    mocked_method.assert_called_with(**expected_call_args)
@pytest.mark.django_db
def test_ssorequestaccessview_post_with_complete_data(admin_client, admin_user, groups_with_info, team_leaders):
    group = groups_with_info[0]
    team_leader = team_leaders[0]
    with patch('users.views.notify_team_leader_of_pending_access_request', autospec=True) as mocked_method:
        response = admin_client.post(reverse('sso:request_access'), data={'self_assigned_group': group.id, 'team_leader': team_leader.id})
    success_url = reverse('sso:request_access_success')
    assert (response.url == success_url)
    profile = admin_user.userprofile
    assert (profile.self_assigned_group_id == group.id)
    assert (profile.team_leader_id == team_leader.id)
    assert (profile.assignment_status == UserProfile.STATUS_AWAITING_APPROVAL)
    expected_call_args = dict(request=response.wsgi_request, team_leader_email=team_leader.email, team_leader_name=team_leader.first_name, user_id=admin_user.id, user_name=admin_user.get_full_name(), user_email=admin_user.email, user_role=group.info.name_singular)
    mocked_method.assert_called_with(**expected_call_args)