|
1 | | -from git_autograder import GitAutograderTestLoader |
| 1 | +from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output |
2 | 2 |
|
3 | | -from ..verify import verify |
| 3 | +from ..verify import ( |
| 4 | + FEATURE_SEARCH_BRANCH_STILL_EXISTS, |
| 5 | + FEATURE_DELETE_BRANCH_STILL_EXISTS, |
| 6 | + FEATURES_FILE_CONTENT_INVALID, |
| 7 | + LIST_BRANCH_STILL_EXISTS, |
| 8 | + MISMATCH_COMMIT_MESSAGE, |
| 9 | + SQUASH_NOT_USED, |
| 10 | + verify, |
| 11 | +) |
4 | 12 |
|
5 | 13 | REPOSITORY_NAME = "mix-messy-graph" |
6 | 14 |
|
7 | 15 | loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify) |
8 | 16 |
|
9 | 17 |
|
10 | 18 | def test_base(): |
11 | | - with loader.load("specs/base.yml", "start"): |
12 | | - pass |
| 19 | + with loader.load("specs/base.yml") as output: |
| 20 | + assert_output(output, GitAutograderStatus.SUCCESSFUL) |
| 21 | + |
| 22 | + |
| 23 | +def test_non_squash_merge_used(): |
| 24 | + with loader.load("specs/non_squash_merge_used.yml") as output: |
| 25 | + assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [SQUASH_NOT_USED]) |
| 26 | + |
| 27 | + |
| 28 | +def test_wrong_commit_message(): |
| 29 | + with loader.load("specs/wrong_commit_message.yml") as output: |
| 30 | + assert_output( |
| 31 | + output, |
| 32 | + GitAutograderStatus.UNSUCCESSFUL, |
| 33 | + [ |
| 34 | + MISMATCH_COMMIT_MESSAGE.format( |
| 35 | + expected="Add the search feature", given="Add the search feature!" |
| 36 | + ) |
| 37 | + ], |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +def test_missing_commit(): |
| 42 | + with loader.load("specs/missing_commit.yml") as output: |
| 43 | + assert_output( |
| 44 | + output, |
| 45 | + GitAutograderStatus.UNSUCCESSFUL, |
| 46 | + [ |
| 47 | + MISMATCH_COMMIT_MESSAGE.format( |
| 48 | + expected="Add the delete feature", given="<Missing commit>" |
| 49 | + ) |
| 50 | + ], |
| 51 | + ) |
| 52 | + |
| 53 | + |
| 54 | +def test_branches_not_deleted(): |
| 55 | + with loader.load("specs/branches_not_deleted.yml") as output: |
| 56 | + assert_output( |
| 57 | + output, |
| 58 | + GitAutograderStatus.UNSUCCESSFUL, |
| 59 | + [ |
| 60 | + FEATURE_SEARCH_BRANCH_STILL_EXISTS, |
| 61 | + FEATURE_DELETE_BRANCH_STILL_EXISTS, |
| 62 | + LIST_BRANCH_STILL_EXISTS, |
| 63 | + ], |
| 64 | + ) |
| 65 | + |
| 66 | + |
| 67 | +def test_features_content_invalid(): |
| 68 | + with loader.load("specs/features_content_invalid.yml") as output: |
| 69 | + assert_output( |
| 70 | + output, |
| 71 | + GitAutograderStatus.UNSUCCESSFUL, |
| 72 | + [FEATURES_FILE_CONTENT_INVALID], |
| 73 | + ) |
0 commit comments