Skip to content

Commit

Permalink
Integration tests for plan collaborators
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermak committed Oct 2, 2023
1 parent d107f66 commit 53bffa3
Showing 1 changed file with 75 additions and 1 deletion.
76 changes: 75 additions & 1 deletion tests/integration_tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aerie_cli.__main__ import app
from aerie_cli.commands import plans

from .conftest import client, HASURA_ADMIN_SECRET, DOWNLOADED_FILE_NAME
from .conftest import client, DOWNLOADED_FILE_NAME, ADDITIONAL_USERS

runner = CliRunner(mix_stderr = False)

Expand Down Expand Up @@ -109,6 +109,80 @@ def test_plan_list():
assert "Current Activity Plans" in result.stdout


#######################
# ADD/LIST/DELETE COLLABORATORS
# Uses plan
#######################


def test_list_empty_plan_collaborators():
"""
Should be no plan collaborators to start
"""
result = runner.invoke(
app,
["plans", "collaborators", "list"],
input=str(plan_id) + "\n",
catch_exceptions=False,
)
assert result.exit_code == 0, f"{result.stdout}" f"{result.stderr}"

assert "No collaborators" in result.stdout


def test_add_collaborators():
"""
Add all users as collaborators and check the final list
"""

# Add all additional users as collaborators
for username in ADDITIONAL_USERS:
result = runner.invoke(
app,
["plans", "collaborators", "add"],
input=str(plan_id) + "\n" + username + "\n",
catch_exceptions=False,
)
assert result.exit_code == 0, f"{result.stdout} {result.stderr}"

assert "Success" in result.stdout

# Check full list of collaborators
assert ADDITIONAL_USERS == client.list_plan_collaborators(plan_id)


def test_list_plan_collaborators():
"""
Check that the `plans collaborators list` command lists all collaborators
"""
result = runner.invoke(
app,
["plans", "collaborators", "list"],
input=str(plan_id) + "\n",
catch_exceptions=False,
)
assert result.exit_code == 0, f"{result.stdout} {result.stderr}"

for username in ADDITIONAL_USERS:
assert username in result.stdout


def test_delete_collaborators():
"""
Delete a collaborator and verify the result
"""
user_to_delete = ADDITIONAL_USERS[0]
result = runner.invoke(
app,
["plans", "collaborators", "delete"],
input=str(plan_id) + "\n" + "1" + "\n",
catch_exceptions=False,
)
assert result.exit_code == 0, f"{result.stdout} {result.stderr}"

assert "Success" in result.stdout


#######################
# SIMULATE PLAN
# Uses plan
Expand Down

0 comments on commit 53bffa3

Please sign in to comment.