|
1 | 1 | from contextlib import contextmanager |
2 | 2 | from typing import Iterator, Tuple |
3 | 3 |
|
4 | | -from repo_smith.repo_smith import RepoSmith |
5 | 4 | from exercise_utils.test import ( |
6 | 5 | GitAutograderTest, |
7 | 6 | GitAutograderTestLoader, |
8 | 7 | assert_output, |
9 | 8 | ) |
10 | 9 | from git_autograder.status import GitAutograderStatus |
| 10 | +from repo_smith.repo_smith import RepoSmith |
11 | 11 |
|
12 | 12 | from .verify import ( |
13 | 13 | MISSING_BRANCH, |
14 | 14 | MISSING_COMMIT, |
| 15 | + MISSING_LOCATION_COMMIT, |
| 16 | + MISSING_STORY_FILE, |
15 | 17 | WRONG_CONTENT, |
16 | 18 | WRONG_START, |
17 | 19 | verify, |
@@ -58,6 +60,52 @@ def test_base(): |
58 | 60 | assert_output(output, GitAutograderStatus.SUCCESSFUL) |
59 | 61 |
|
60 | 62 |
|
| 63 | +def test_location_commit_missing(): |
| 64 | + with loader.start() as (test, rs): |
| 65 | + rs.files.create_or_update("story.txt", "It was a dark and stormy night.") |
| 66 | + rs.git.add(all=True) |
| 67 | + rs.git.commit(message="Describe night") |
| 68 | + |
| 69 | + rs.files.append("story.txt", "I heard a strange noise.") |
| 70 | + rs.git.add(all=True) |
| 71 | + rs.git.commit(message="Mention noise") |
| 72 | + |
| 73 | + output = test.run() |
| 74 | + assert_output( |
| 75 | + output, GitAutograderStatus.UNSUCCESSFUL, [MISSING_LOCATION_COMMIT] |
| 76 | + ) |
| 77 | + |
| 78 | + |
| 79 | +def test_story_file_missing(): |
| 80 | + with loader.start() as (test, rs): |
| 81 | + rs.files.create_or_update("a.txt", "It was a dark and stormy night.") |
| 82 | + rs.git.add(all=True) |
| 83 | + rs.git.commit(message="Describe night") |
| 84 | + |
| 85 | + rs.files.append("a.txt", "I was alone in my room.") |
| 86 | + rs.git.add(all=True) |
| 87 | + rs.git.commit(message="Describe location") |
| 88 | + |
| 89 | + rs.files.append("a.txt", "I heard a strange noise.") |
| 90 | + rs.git.add(all=True) |
| 91 | + rs.git.commit(message="Mention noise") |
| 92 | + |
| 93 | + rs.git.checkout("visitor-line", start_point="HEAD~1", branch=True) |
| 94 | + |
| 95 | + rs.files.append("a.txt", "I heard someone knocking at the door.") |
| 96 | + rs.git.add(all=True) |
| 97 | + rs.git.commit(message="Mention knocking") |
| 98 | + |
| 99 | + rs.git.checkout("sleep-line", start_point="HEAD~1", branch=True) |
| 100 | + |
| 101 | + rs.files.append("a.txt", "I fell asleep on the couch.") |
| 102 | + rs.git.add(all=True) |
| 103 | + rs.git.commit(message="Mention sleeping") |
| 104 | + |
| 105 | + output = test.run() |
| 106 | + assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [MISSING_STORY_FILE]) |
| 107 | + |
| 108 | + |
61 | 109 | def test_visitor_missing_branch(): |
62 | 110 | with base_setup() as (test, rs): |
63 | 111 | rs.git.checkout("sleep-line", start_point="HEAD~1", branch=True) |
|
0 commit comments