Skip to content
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

Hotfixes: Missed name change and permissions nuance #82

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aerie-cli"
version = "2.0.0"
version = "2.0.1"
description = "A CLI application and Python API for interacting with Aerie."
authors = []
license = "MIT"
Expand Down
9 changes: 3 additions & 6 deletions src/aerie_cli/aerie_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ def update_activity(
activity_to_update: Activity,
plan_id: int
) -> int:
activity_dict: Dict = activity_to_update.to_api_create(
plan_id
).to_dict()
activity_dict: Dict = activity_to_update.to_api_update().to_dict()
update_activity_mutation = """
mutation UpdateActvityDirective($id: Int!, $plan_id: Int!, $activity: activity_directive_set_input!) {
updateActivity: update_activity_directive_by_pk(
Expand Down Expand Up @@ -1562,18 +1560,17 @@ def __expand_activity_arguments(self, plan: ActivityPlanRead, full_args: str = N
)
{
arguments
errors
Mythicaeda marked this conversation as resolved.
Show resolved Hide resolved
success
}
}
"""
resp = self.aerie_host.post_to_graphql(
query,
args=activity.parameters,
args=activity.arguments,
act_type=activity.type,
model_id=plan.model_id,
)
activity.parameters = ApiEffectiveActivityArguments.from_dict(
activity.arguments = ApiEffectiveActivityArguments.from_dict(
resp).arguments
return plan

Expand Down
11 changes: 11 additions & 0 deletions src/aerie_cli/schemas/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def from_json(cls, dictionary: Dict) -> "ApiSerialize":
@define
class ApiEffectiveActivityArguments(ApiSerialize):
arguments: Dict[str, Any]
success: bool

@define
class ActivityBase(ApiSerialize):
Expand Down Expand Up @@ -92,6 +93,16 @@ class ApiActivityCreate(ActivityBase):
plan_id: int


@define
class ApiActivityUpdate(ActivityBase):
"""Format for updating activity directives

Plan ID is excluded as this column has restricted permissions for update
"""

pass


@define
class ApiActivityRead(ActivityBase):
"""Format for downloading activity directives
Expand Down
12 changes: 12 additions & 0 deletions src/aerie_cli/schemas/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from aerie_cli.utils.serialization import parse_timedelta_str
from aerie_cli.schemas.api import ApiActivityCreate
from aerie_cli.schemas.api import ApiActivityUpdate
from aerie_cli.schemas.api import ApiActivityPlanCreate
from aerie_cli.schemas.api import ApiActivityPlanRead
from aerie_cli.schemas.api import ApiActivityRead
Expand Down Expand Up @@ -78,6 +79,17 @@ def to_api_create(self, plan_id: int):
anchored_to_start=self.anchored_to_start
)

def to_api_update(self):
return ApiActivityUpdate(
type=self.type,
start_offset=self.start_offset,
arguments=self.arguments,
name=self.name,
metadata=self.metadata,
anchor_id=self.anchor_id,
anchored_to_start=self.anchored_to_start
)

@classmethod
def from_api_read(
cls, api_activity_read: ApiActivityRead
Expand Down
18 changes: 18 additions & 0 deletions tests/integration_tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ def test_plan_download():
f"{result.stderr}"
assert f"Wrote activity plan" in result.stdout

def test_plan_download_expanded_args():
"""
Download a plan, exercising the --full-args option to get effective activity arguments
"""
result = runner.invoke(
app,
["plans", "download", "--full-args", "true"],
input=str(plan_id) + "\n" + DOWNLOADED_FILE_NAME + "\n",
catch_exceptions=False,
)
path_to_plan = Path(DOWNLOADED_FILE_NAME)
assert path_to_plan.exists()
path_to_plan.unlink()
assert result.exit_code == 0,\
f"{result.stdout}"\
f"{result.stderr}"
assert f"Wrote activity plan" in result.stdout

def test_plan_download_resources():
result = runner.invoke(
app,
Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/files/mock_responses/update_activity.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"aParameter": "2030-001T00:00:00Z"
},
"anchor_id": null,
"anchored_to_start": true,
"plan_id": 1
"anchored_to_start": true
}
}
},
Expand Down