Skip to content

Commit f743ceb

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 48463ec + 0f55a78 commit f743ceb

File tree

6 files changed

+5395
-4
lines changed

6 files changed

+5395
-4
lines changed

agiocli/__main__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ def courses(ctx, course_arg, show_list, web): # noqa: D301
8282
@click.option("-l", "--list", "show_list", is_flag=True,
8383
help="List projects and exit.")
8484
@click.option("-w", "--web", is_flag=True, help="Open project in browser.")
85+
@click.option("--config", is_flag=True, help="Get test suite config.")
8586
@click.pass_context
8687
# The \b character in the docstring prevents Click from rewraping a paragraph.
8788
# We need to tell pycodestyle to ignore it.
8889
# https://click.palletsprojects.com/en/8.0.x/documentation/#preventing-rewrapping
89-
def projects(ctx, project_arg, course_arg, show_list, web): # noqa: D301
90+
def projects(ctx, project_arg, course_arg, show_list, web, config): # noqa: D301
9091
"""Show project detail or list projects.
9192
9293
PROJECT_ARG is a primary key, name, or shorthand.
@@ -99,8 +100,10 @@ def projects(ctx, project_arg, course_arg, show_list, web): # noqa: D301
99100
agio projects --course 109 p1
100101
agio projects --course eecs485sp21 p1
101102
agio projects p1
103+
agio projects --course eecs485sp21 p1 --config
102104
103105
"""
106+
# pylint: disable=too-many-arguments
104107
try:
105108
client = APIClient.make_default(debug=ctx.obj["DEBUG"])
106109
except TokenFileNotFound as err:
@@ -114,11 +117,23 @@ def projects(ctx, project_arg, course_arg, show_list, web): # noqa: D301
114117
print(utils.project_str(i))
115118
return
116119

117-
# Select a project and print or open it
120+
# Select a project
118121
project = utils.get_project_smart(project_arg, course_arg, client)
122+
123+
# Print test suite config if --config flag
124+
if config:
125+
config_json = client.get(
126+
f"/api/projects/{project['pk']}/ag_test_suites/"
127+
)
128+
print(utils.dict_str(config_json))
129+
return
130+
131+
# Open project if --web flag
119132
if web:
120133
utils.open_web(f"https://autograder.io/web/project/{project['pk']}")
121134
return
135+
136+
# Otherwise print project info
122137
print(utils.dict_str(project))
123138

124139

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
description="A command line interface to autograder.io",
1616
long_description=LONG_DESCRIPTION,
1717
long_description_content_type="text/markdown",
18-
version="0.3.0",
18+
version="0.4.0",
1919
author="Andrew DeOrio",
2020
author_email="[email protected]",
2121
url="https://github.com/eecs485staff/agio-cli/",

tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Shared test fixtures."""
22
import json
33
import pytest
4+
import utils
45

56

67
@pytest.fixture(name="constants")
@@ -138,7 +139,7 @@ def constants_setup():
138139
"grading_start_time": "2021-06-09T12:49:21.340598Z",
139140
"non_deferred_grading_end_time": "2021-06-09T12:50:26.978440Z",
140141
"last_modified": "2021-06-09T12:50:25.899462Z"
141-
}
142+
},
142143
}
143144

144145

@@ -551,3 +552,12 @@ def api_requests_mock(requests_mock, mocker, constants):
551552
headers={"Content-Type": "application/json"},
552553
text=json.dumps(constants["SUBMISSION_1125717"]),
553554
)
555+
556+
# Project autograder configuration
557+
config_path = utils.TESTDATA_DIR/"eecs485sp21_p1_config.json"
558+
config_text = config_path.read_text()
559+
requests_mock.get(
560+
"https://autograder.io/api/projects/1005/ag_test_suites/",
561+
headers={"Content-Type": "application/json"},
562+
text=config_text,
563+
)

tests/test_projects.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"""
66
import json
77
import textwrap
8+
import shlex
89
import click
910
import click.testing
11+
import utils
1012
from agiocli.__main__ import main
1113

1214

@@ -150,3 +152,25 @@ def test_projects_empty(api_mock, mocker, constants):
150152
assert result.exit_code == 0, result.output
151153
output_obj = json.loads(result.output)
152154
assert output_obj["pk"] == 1005
155+
156+
157+
def test_projects_config(api_mock, mocker, constants):
158+
"""Verify projects subcommand with --config option.
159+
160+
$ agio projects -c eecs485sp21 p1 --config
161+
162+
api_mock is a shared test fixture that mocks responses to REST API
163+
requests. It is implemented in conftest.py
164+
165+
"""
166+
runner = click.testing.CliRunner()
167+
result = runner.invoke(
168+
main, shlex.split("projects -c eecs485sp21 p1 --config"),
169+
catch_exceptions=False,
170+
)
171+
assert result.exit_code == 0, result.output
172+
output = json.loads(result.output)
173+
expected_path = utils.TESTDATA_DIR/"eecs485sp21_p1_config.json"
174+
with expected_path.open(encoding="utf-8") as infile:
175+
expected = json.load(infile)
176+
assert output == expected

0 commit comments

Comments
 (0)