Skip to content

Commit

Permalink
Improve code coverage for scheduler module (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr committed Sep 17, 2022
1 parent 5de8142 commit b9ea4c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
11 changes: 1 addition & 10 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,6 @@ impl DepthFirstScheduler {
.get_dependencies(unit_id)
.unwrap_or_default()
.into_iter()
.filter(|dependency_id| {
// Ignore the implicit dependency between a lesson and its course.
if let Some(course_id) = self.data.unit_graph.read().get_lesson_course(unit_id) {
if course_id == *dependency_id {
return false;
}
}
true
})
.all(|dependency_id| self.satisfied_dependency(&dependency_id, metadata_filter))
}

Expand Down Expand Up @@ -565,7 +556,7 @@ impl DepthFirstScheduler {
let (candidates, _) = self.get_candidates_from_lesson_helper(&StackItem {
unit_id: *lesson_id,
num_hops: 0,
})?;
})?; // grcov-excl-line
Ok(candidates)
}

Expand Down
23 changes: 20 additions & 3 deletions tests/basic_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ lazy_static! {
},
TestCourse {
id: TestId(5, None, None),
dependencies: vec![TestId(3, None, None), TestId(4, None, None)],
dependencies: vec![
TestId(3, None, None), // Depend on a missing course.
TestId(4, None, None)
],
metadata: BTreeMap::from([
(
"course_key_1".to_string(),
Expand Down Expand Up @@ -381,7 +384,10 @@ lazy_static! {
},
TestLesson {
id: TestId(7, Some(1), None),
dependencies: vec![TestId(0, Some(0), None)],
dependencies: vec![
TestId(0, Some(0), None),
TestId(6, Some(11), None), // Depend on a missing lesson.
],
metadata: BTreeMap::from([
(
"lesson_key_1".to_string(),
Expand Down Expand Up @@ -586,7 +592,18 @@ fn avoid_scheduling_exercises_in_blacklist() -> Result<()> {

// Run the simulation.
let mut simulation = TraneSimulation::new(500, Box::new(|_| Some(MasteryScore::Five)));
let exercise_blacklist = vec![TestId(2, Some(1), Some(7)), TestId(4, Some(0), Some(0))];
let exercise_blacklist = vec![
TestId(2, Some(1), Some(0)),
TestId(2, Some(1), Some(1)),
TestId(2, Some(1), Some(2)),
TestId(2, Some(1), Some(3)),
TestId(2, Some(1), Some(4)),
TestId(2, Some(1), Some(5)),
TestId(2, Some(1), Some(6)),
TestId(2, Some(1), Some(7)),
TestId(2, Some(1), Some(8)),
TestId(2, Some(1), Some(9)),
];
simulation.run_simulation(&mut trane, &exercise_blacklist, None)?;

// Every exercise ID should be in `simulation.answer_history` except for those in the blacklist.
Expand Down

0 comments on commit b9ea4c0

Please sign in to comment.