Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich committed May 12, 2023
1 parent 60d51ac commit bad6e32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lightning/app/utilities/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def _get_project(client: LightningClient, organization_id: Optional[str] = None,
if organization_id is None:
organization_id = constants.LIGHTNING_CLOUD_ORGANIZATION_ID

projects = client.projects_service_list_memberships(organization_id=organization_id)
projects = client.projects_service_list_memberships(
**({"organization_id": organization_id} if organization_id is not None else {})
)
if project_id is not None:
for membership in projects.memberships:
if membership.project_id == project_id:
Expand Down
9 changes: 9 additions & 0 deletions tests/tests_app/utilities/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ def test_get_project_picks_up_organization_id():
lightning_client.projects_service_list_memberships.assert_called_once_with(organization_id="organization_id")


def test_get_project_doesnt_pass_organization_id_if_its_not_set():
lightning_client = LightningClient()
lightning_client.projects_service_list_memberships = mock.MagicMock(
return_value=V1ListMembershipsResponse(memberships=[V1Membership(project_id="project_id")]),
)
_get_project(lightning_client)
lightning_client.projects_service_list_memberships.assert_called_once_with()


def test_is_running_cloud():
"""We can determine if Lightning is running in the cloud."""
with mock.patch.dict(os.environ, {}, clear=True):
Expand Down

0 comments on commit bad6e32

Please sign in to comment.