Skip to content

Commit

Permalink
Update scheduling integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelCourtney committed Aug 15, 2024
1 parent 3346131 commit ff7d76f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/aerie_cli/commands/goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def new(
None, '--plan', '-p', help="Plan ID of the specification to add this to"
)
):
"""Upload new scheduling goal"""

client = CommandContext.get_client()
filename, extension = _get_name_and_ext(path)
if name is None:
Expand Down Expand Up @@ -63,6 +65,7 @@ def update(
goal_id: Optional[int] = typer.Option(None, '--goal', '-g', help="Goal ID of goal to be updated (will search by name if omitted)"),
name: Optional[str] = typer.Option(None, '--name', '-n', help="Name of the goal to be updated (ignored if goal is provided, default is the file name without extension)"),
):
"""Upload an update to a scheduling goal"""
client = CommandContext.get_client()
filename, extension = _get_name_and_ext(path)
if goal_id is None:
Expand All @@ -87,7 +90,7 @@ def update(
@app.command()
def delete(
goal_id: int = typer.Option(
..., help="Goal ID of goal to be deleted", prompt=True
..., '--goal', '-g', help="Goal ID of goal to be deleted", prompt=True
)
):
"""Delete scheduling goal"""
Expand Down
13 changes: 4 additions & 9 deletions tests/integration_tests/test_goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,25 @@ def set_up_environment(request):
#######################

def cli_schedule_upload():
schedule_file_path = os.path.join(GOALS_PATH, "schedule1.txt")
with open(schedule_file_path, "w") as fid:
fid.write(GOAL_PATH)
result = runner.invoke(
app,
["goals", "upload"],
input=str(model_id) + "\n" + str(plan_id) + "\n" + schedule_file_path + "\n",
["goals", "new", GOALS_PATH, "-p", plan_id],
catch_exceptions=False,
)
os.remove(schedule_file_path)
return result

def test_schedule_upload():
result = cli_schedule_upload()
assert result.exit_code == 0,\
f"{result.stdout}"\
f"{result.stderr}"
assert "Assigned goals in priority order" in result.stdout
assert "Uploaded scheduling goal to venue." in result.stdout
global goal_id
for line in result.stdout.splitlines():
if not "Assigned goals in priority order" in line:
if not "Uploaded scheduling goal to venue" in line:
continue
# get expansion id from the end of the line
goal_id = int(line.split("ID ")[1][:-1])
goal_id = int(line.split("ID: ")[1])
assert goal_id != -1, "Could not find goal ID, goal upload may have failed"\
f"{result.stdout}"\
f"{result.stderr}"
Expand Down

0 comments on commit ff7d76f

Please sign in to comment.