Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjra2611 committed Oct 16, 2023
1 parent eff711f commit 8aeacbb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lean/commands/cloud/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def pull(project: Optional[str], pull_bootcamp: bool, encrypt: Optional[bool], d
raise RuntimeError(f"Cannot encrypt or decrypt more than one project at a time.")

pull_manager = container.pull_manager
pull_manager.pull_projects(projects_to_pull, encryption_action, key, all_projects)
pull_manager.pull_projects(projects_to_pull, all_projects, encryption_action, key)
3 changes: 1 addition & 2 deletions lean/components/cloud/pull_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def _get_libraries(self, project: QCProject,

return libraries, inaccessible_libraries

def pull_projects(self, projects_to_pull: List[QCProject], encryption_action: Optional[ActionType], encryption_key: Optional[Path],
all_cloud_projects: Optional[List[QCProject]] = None) -> None:
def pull_projects(self, projects_to_pull: List[QCProject], all_cloud_projects: Optional[List[QCProject]] = None, encryption_action: Optional[ActionType]=None, encryption_key: Optional[Path]=None) -> None:
"""Pulls the given projects from the cloud to the local drive.
This will also pull libraries referenced by the project.
Expand Down
8 changes: 4 additions & 4 deletions lean/components/cloud/push_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self,
self._organization_manager = organization_manager
self._cloud_projects = []

def push_project(self, project: Path, encryption_action: Optional[ActionType], encryption_key: Optional[Path]) -> None:
def push_project(self, project: Path, encryption_action: Optional[ActionType]=None, encryption_key: Optional[Path]=None) -> None:
"""Pushes the given project from the local drive to the cloud.
It will also push every library referenced by the project and add or remove references.
Expand All @@ -58,7 +58,7 @@ def push_project(self, project: Path, encryption_action: Optional[ActionType], e
libraries = self._project_manager.get_project_libraries(project)
self.push_projects(libraries + [project], encryption_action, encryption_key)

def push_projects(self, projects_to_push: List[Path], encryption_action: Optional[ActionType], encryption_key: Optional[Path]) -> None:
def push_projects(self, projects_to_push: List[Path], encryption_action: Optional[ActionType]=None, encryption_key: Optional[Path]=None) -> None:
"""Pushes the given projects from the local drive to the cloud.
It will also push every library referenced by each project and add or remove references.
Expand Down Expand Up @@ -167,10 +167,10 @@ def _get_files(self, project: Path, encryption_action: Optional[ActionType], enc
if (encryption_key):
organization_id = self._organization_manager.try_get_working_organization_id()
if encryption_action == ActionType.ENCRYPT:
data = get_encrypted_file_content_for_project(project, paths,
data = get_encrypted_file_content_for_project(project, paths,
encryption_key, self._project_config_manager, organization_id)
else:
data = get_decrypted_file_content_for_project(project,
data = get_decrypted_file_content_for_project(project,
paths, encryption_key, self._project_config_manager, organization_id)
files = [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/cloud/test_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_cloud_pull_pulls_all_non_bootcamp_projects_when_no_options_given() -> N

assert result.exit_code == 0

pull_manager.pull_projects.assert_called_once_with(cloud_projects[:3], None, None, cloud_projects)
pull_manager.pull_projects.assert_called_once_with(cloud_projects[:3], cloud_projects, None, None)


def test_cloud_pull_pulls_all_projects_when_pull_bootcamp_option_given() -> None:
Expand All @@ -75,7 +75,7 @@ def test_cloud_pull_pulls_all_projects_when_pull_bootcamp_option_given() -> None

assert result.exit_code == 0

pull_manager.pull_projects.assert_called_once_with(cloud_projects, None, None, cloud_projects)
pull_manager.pull_projects.assert_called_once_with(cloud_projects, cloud_projects, None, None)


def test_cloud_pull_pulls_project_by_id() -> None:
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_cloud_pull_pulls_project_by_name() -> None:

assert result.exit_code == 0

pull_manager.pull_projects.assert_called_once_with([cloud_projects[0]], None, None, cloud_projects)
pull_manager.pull_projects.assert_called_once_with([cloud_projects[0]], cloud_projects, None, None)


def test_cloud_pull_aborts_when_project_input_matches_no_cloud_projects() -> None:
Expand Down
4 changes: 3 additions & 1 deletion tests/components/util/test_pull_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def _create_pull_manager(api_client: mock.Mock,
logger = mock.Mock()
platform_manager = mock.Mock()
project_manager = container.project_manager
return PullManager(logger, api_client, project_manager, project_config_manager, library_manager, platform_manager)
organization_manager = container.organization_manager
return PullManager(logger, api_client, project_manager,
project_config_manager, library_manager, platform_manager, organization_manager)


def _make_cloud_projects_and_libraries(project_count: int,
Expand Down

0 comments on commit 8aeacbb

Please sign in to comment.