Skip to content

Commit 5103601

Browse files
committed
test fixes
1 parent e805507 commit 5103601

File tree

2 files changed

+31
-37
lines changed

2 files changed

+31
-37
lines changed

tmc-client/src/tmc_client/api_v8.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ fn assert_success(response: Response, url: &Url) -> Result<Response, ClientError
7070
}
7171
}
7272

73+
/// Fetches data from the URL and writes it into the target.
74+
pub fn download(client: &TmcClient, url: Url, mut target: impl Write) -> Result<(), ClientError> {
75+
let res = prepare_tmc_request(client, Method::GET, url.clone())
76+
.send()
77+
.map_err(|e| ClientError::ConnectionError(Method::GET, url.clone(), e))?;
78+
79+
let mut res = assert_success(res, &url)?;
80+
let _bytes = res
81+
.copy_to(&mut target)
82+
.map_err(ClientError::HttpWriteResponse)?;
83+
Ok(())
84+
}
85+
7386
/// Fetches JSON from the given URL and deserializes it into T.
7487
pub fn get_json<T: DeserializeOwned>(
7588
client: &TmcClient,
@@ -88,19 +101,6 @@ pub fn get_json<T: DeserializeOwned>(
88101
Ok(json)
89102
}
90103

91-
// fetches data from the URL and writes it into target
92-
fn download(client: &TmcClient, url: Url, mut target: impl Write) -> Result<(), ClientError> {
93-
let res = prepare_tmc_request(client, Method::GET, url.clone())
94-
.send()
95-
.map_err(|e| ClientError::ConnectionError(Method::GET, url.clone(), e))?;
96-
97-
let mut res = assert_success(res, &url)?;
98-
let _bytes = res
99-
.copy_to(&mut target)
100-
.map_err(ClientError::HttpWriteResponse)?;
101-
Ok(())
102-
}
103-
104104
/// get /api/v8/application/{client_name}/credentials
105105
/// Fetches oauth2 credentials info.
106106
pub fn get_credentials(client: &TmcClient, client_name: &str) -> Result<Credentials, ClientError> {

tmc-langs-cli/src/app.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub enum Core {
251251
#[structopt(long)]
252252
submission_id: u32,
253253
/// If set, the exercise is submitted to the server before resetting it.
254-
#[structopt(long, requires = "submission-url")]
254+
#[structopt(long)]
255255
save_old_state: bool,
256256
/// The ID of the exercise.
257257
#[structopt(long)]
@@ -430,7 +430,7 @@ pub enum Core {
430430
#[structopt(long_about = SCHEMA_NULL)]
431431
ResetExercise {
432432
/// If set, the exercise is submitted to the server before resetting it.
433-
#[structopt(long, requires = "submission-url")]
433+
#[structopt(long)]
434434
save_old_state: bool,
435435
/// The ID of the exercise.
436436
#[structopt(long)]
@@ -804,8 +804,8 @@ mod core_test {
804804
fn download_model_solution() {
805805
get_matches_core(&[
806806
"download-model-solution",
807-
"--solution-download-url",
808-
"http://localhost",
807+
"--exercise-id",
808+
"0",
809809
"--target",
810810
"path",
811811
]);
@@ -822,8 +822,6 @@ mod core_test {
822822
"path",
823823
"--submission-id",
824824
"2345",
825-
"--submission-url",
826-
"http://localhost",
827825
]);
828826
}
829827

@@ -900,7 +898,7 @@ mod core_test {
900898

901899
#[test]
902900
fn get_unread_reviews() {
903-
get_matches_core(&["get-unread-reviews", "--reviews-url", "http://localhost"]);
901+
get_matches_core(&["get-unread-reviews", "--course-id", "0"]);
904902
}
905903

906904
#[test]
@@ -929,8 +927,10 @@ mod core_test {
929927
fn mark_review_as_read() {
930928
get_matches_core(&[
931929
"mark-review-as-read",
932-
"--review-update-url",
933-
"http://localhost",
930+
"--course-id",
931+
"0",
932+
"--review-id",
933+
"1",
934934
]);
935935
}
936936

@@ -944,8 +944,8 @@ mod core_test {
944944
"msg",
945945
"--submission-path",
946946
"path",
947-
"--submission-url",
948-
"http://localhost",
947+
"--exercise-id",
948+
"0",
949949
]);
950950
}
951951

@@ -959,8 +959,8 @@ mod core_test {
959959
"msg",
960960
"--submission-path",
961961
"path",
962-
"--submission-url",
963-
"http://localhost",
962+
"--exercise-id",
963+
"0",
964964
]);
965965
}
966966

@@ -973,8 +973,6 @@ mod core_test {
973973
"1234",
974974
"--exercise-path",
975975
"path",
976-
"--submission-url",
977-
"http://localhost",
978976
]);
979977
}
980978

@@ -985,8 +983,8 @@ mod core_test {
985983
"--feedback",
986984
"1234",
987985
"answer",
988-
"--feedback-url",
989-
"http://localhost",
986+
"--submission-id",
987+
"0",
990988
]);
991989
}
992990

@@ -999,8 +997,8 @@ mod core_test {
999997
"fi",
1000998
"--submission-path",
1001999
"path",
1002-
"--submission-url",
1003-
"http://localhost",
1000+
"--exercise-id",
1001+
"0",
10041002
]);
10051003
}
10061004

@@ -1011,11 +1009,7 @@ mod core_test {
10111009

10121010
#[test]
10131011
fn wait_for_submission() {
1014-
get_matches_core(&[
1015-
"wait-for-submission",
1016-
"--submission-url",
1017-
"http://localhost",
1018-
]);
1012+
get_matches_core(&["wait-for-submission", "--submission-id", "0"]);
10191013
}
10201014
}
10211015

0 commit comments

Comments
 (0)