fix org invite tests

This commit is contained in:
Kenneth Kehl
2025-09-09 08:24:33 -07:00
parent a85a540abd
commit 3d7aee19d2
3 changed files with 16 additions and 14 deletions

View File

@@ -276,7 +276,9 @@ def set_up_your_profile():
current_app.logger.info(f"#invites redirecting to {url}")
return redirect(url)
else:
usr = User.from_id(user["id"])
org_id = invite_data["organization"]
usr.add_to_organization(org_id)
url = url_for(".organization_dashboard", org_id=org_id)
current_app.logger.info(f"#invites redirecting to {url}")
return redirect(url)

View File

@@ -259,7 +259,7 @@ class User(JSONModel, UserMixin):
# TODO this is sketch! Fix this!
# This is temporary to restore org invite functionality only
self.add_to_organization(org_id)
# self.add_to_organization(org_id)
value = self.belongs_to_organization(org_id)
current_app.logger.debug(
f"has_permissions returns org: {org_id} returning {value}"
@@ -326,8 +326,8 @@ class User(JSONModel, UserMixin):
# TODO this is sketch! Fix this!
# This is temporary to restore org invite functionality only
if str(organization_id) not in self.organization_ids:
self.add_to_organization(organization_id)
# if str(organization_id) not in self.organization_ids:
# self.add_to_organization(organization_id)
return str(organization_id) in self.organization_ids
@property

View File

@@ -19,15 +19,15 @@ from tests.conftest import (
("user_services", "user_organizations", "expected_status", "organization_checked"),
[
([SERVICE_ONE_ID], [], 200, False),
([SERVICE_ONE_ID, SERVICE_TWO_ID], [], 201, False),
([], [ORGANISATION_ID], 202, True),
([SERVICE_ONE_ID], [ORGANISATION_ID], 203, False),
# ([], [], 403, True),
# ([SERVICE_TWO_ID], [], 403, True),
([SERVICE_TWO_ID], [ORGANISATION_ID], 204, True),
([SERVICE_ONE_ID, SERVICE_TWO_ID], [ORGANISATION_ID], 205, False),
# ([], [ORGANISATION_TWO_ID], 403, True),
([], [ORGANISATION_ID, ORGANISATION_TWO_ID], 206, True),
([SERVICE_ONE_ID, SERVICE_TWO_ID], [], 200, False),
([], [ORGANISATION_ID], 200, True),
([SERVICE_ONE_ID], [ORGANISATION_ID], 200, False),
([], [], 403, True),
([SERVICE_TWO_ID], [], 403, True),
([SERVICE_TWO_ID], [ORGANISATION_ID], 200, True),
([SERVICE_ONE_ID, SERVICE_TWO_ID], [ORGANISATION_ID], 200, False),
([], [ORGANISATION_TWO_ID], 403, True),
([], [ORGANISATION_ID, ORGANISATION_TWO_ID], 200, True),
],
)
def test_services_pages_that_org_users_are_allowed_to_see(
@@ -81,8 +81,8 @@ def test_services_pages_that_org_users_are_allowed_to_see(
endpoint,
service_id=SERVICE_ONE_ID,
_expected_status=expected_status,
nonce="nonce",
state="state",
nonce="dummy-nonce",
state="dummy-state",
)
assert mock_get_service.called is organization_checked