-
Notifications
You must be signed in to change notification settings - Fork 26
Implement exercise T4L1/view-commits #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4d6d6d
Implement exercise view-commits
SAN-MUYUN 2e63d5d
fix code quality
SAN-MUYUN 6da3984
Merge branch 'main' of https://github.com/SAN-MUYUN/git-mastery-exerc…
SAN-MUYUN 35ae4c2
update README
SAN-MUYUN a5e7138
[view-commits] Clean up test_verify.py
jovnc 6df46dc
[view-commits] Run ruff format
jovnc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "exercise_name": "view-commits", | ||
| "tags": [ | ||
| "git-diff", | ||
| "git-show" | ||
| ], | ||
| "requires_git": true, | ||
| "requires_github": true, | ||
| "base_files": { | ||
| "answers.txt": "answers.txt" | ||
| }, | ||
| "exercise_repo": { | ||
| "repo_type": "remote", | ||
| "repo_name": "duty-roster", | ||
| "repo_title": "gm-duty-roster", | ||
| "create_fork": false, | ||
| "init": true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| See https://git-mastery.github.io/lessons/show/exercise-view-commits.html |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| def setup(verbose: bool = False): ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Q: In February, who was replaced in the Wednesday duty roster? | ||
| A: | ||
|
|
||
| Q: In February, who joined the Tuesday duty roster? | ||
| A: | ||
|
|
||
| Q: In April, what were the new names added to the duty rosters? Remove/add extra rows where appropriate. | ||
| A: | ||
| - name1 | ||
| - name2 | ||
|
|
||
| Q: In January, who were in the Tuesday duty roster? Remove/add extra rows where appropriate. | ||
| A: | ||
| - name1 | ||
| - name2 | ||
|
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| initialization: | ||
| steps: | ||
| - type: commit | ||
| empty: true | ||
| message: Empty commit | ||
| id: start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output | ||
| from git_autograder.answers.rules import ( | ||
| HasExactValueRule, | ||
| HasExactListRule, | ||
| NotEmptyRule, | ||
| ContainsListRule, | ||
| ) | ||
| from ..verify import QUESTION_ONE, QUESTION_TWO, QUESTION_THREE, QUESTION_FOUR, verify | ||
|
|
||
| REPOSITORY_NAME = "view-commits" | ||
|
|
||
| loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify) | ||
|
|
||
| CORRECT_QUESTION_ONE = "Eric" | ||
| CORRECT_QUESTION_TWO = "Bruce" | ||
| CORRECT_QUESTION_THREE = """ | ||
| - Beth | ||
| - Betsy | ||
| - Daisy | ||
| """ | ||
| CORRECT_QUESTION_FOUR = "- Charlie" | ||
|
|
||
| WRONG_QUESTION_ONE = "Ergodic" | ||
| WRONG_QUESTION_TWO = "Bru" | ||
| INCOMPLETE_QUESTION_THREE = """ | ||
| - Betsy | ||
| - Daisy | ||
| """ | ||
| WRONG_QUESTION_THREE = """ | ||
| - Betsy | ||
| - Bruce | ||
| - Daisy | ||
| """ | ||
| EXTRA_QUESTION_THREE = """ | ||
| - Betsy | ||
| - Beth | ||
| - Eric | ||
| - Daisy | ||
| """ | ||
| WRONG_QUESTION_FOUR = "- Dave" | ||
|
|
||
|
|
||
| def test_no_answers(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: "", | ||
| QUESTION_TWO: "", | ||
| QUESTION_THREE: "", | ||
| QUESTION_FOUR: "", | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [ | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_ONE), | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_TWO), | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_THREE), | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_FOUR), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| def test_incomplete_answer(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: "", | ||
| QUESTION_FOUR: "", | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [ | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_THREE), | ||
| NotEmptyRule.EMPTY.format(question=QUESTION_FOUR), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| def test_wrong_question_one(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: WRONG_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: CORRECT_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [HasExactValueRule.NOT_EXACT.format(question=QUESTION_ONE)], | ||
| ) | ||
|
|
||
|
|
||
| def test_wrong_question_two(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: WRONG_QUESTION_TWO, | ||
| QUESTION_THREE: CORRECT_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [HasExactValueRule.NOT_EXACT.format(question=QUESTION_TWO)], | ||
| ) | ||
|
|
||
|
|
||
| def test_incomplete_question_three(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: INCOMPLETE_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [HasExactListRule.INCORRECT_UNORDERED.format(question=QUESTION_THREE)], | ||
| ) | ||
|
|
||
|
|
||
| def test_wrong_question_three(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: WRONG_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [ | ||
| HasExactListRule.INCORRECT_UNORDERED.format(question=QUESTION_THREE), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| def test_wrong_question_three_extra_answer(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: EXTRA_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output( | ||
| output, | ||
| GitAutograderStatus.UNSUCCESSFUL, | ||
| [ContainsListRule.INVALID_ITEM.format(question=QUESTION_THREE)], | ||
| ) | ||
|
|
||
|
|
||
| def test_valid_answers(): | ||
| with loader.load( | ||
| "specs/base.yml", | ||
| mock_answers={ | ||
| QUESTION_ONE: CORRECT_QUESTION_ONE, | ||
| QUESTION_TWO: CORRECT_QUESTION_TWO, | ||
| QUESTION_THREE: CORRECT_QUESTION_THREE, | ||
| QUESTION_FOUR: CORRECT_QUESTION_FOUR, | ||
| }, | ||
| ) as output: | ||
| assert_output(output, GitAutograderStatus.SUCCESSFUL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from git_autograder import ( | ||
| GitAutograderOutput, | ||
| GitAutograderExercise, | ||
| GitAutograderStatus, | ||
| ) | ||
| from git_autograder.answers.rules import ( | ||
| HasExactValueRule, | ||
| NotEmptyRule, | ||
| HasExactListRule, | ||
| ContainsListRule, | ||
| ) | ||
|
|
||
| QUESTION_ONE = "In February, who was replaced in the Wednesday duty roster?" | ||
| QUESTION_TWO = "In February, who joined the Tuesday duty roster?" | ||
| QUESTION_THREE = "In April, what were the new names added to the duty rosters? Give the list of names as one line, separated by spaces." | ||
| QUESTION_FOUR = "In January, who were in the Tuesday duty roster? Give the list of names as one line, separated by spaces." | ||
|
|
||
|
|
||
| def verify(exercise: GitAutograderExercise) -> GitAutograderOutput: | ||
| ( | ||
| exercise.answers.add_validation(QUESTION_ONE, NotEmptyRule()) | ||
| .add_validation(QUESTION_ONE, HasExactValueRule("Eric", is_case_sensitive=True)) | ||
| .add_validation( | ||
| QUESTION_TWO, | ||
| NotEmptyRule(), | ||
| HasExactValueRule("Bruce", is_case_sensitive=True), | ||
| ) | ||
| .add_validation( | ||
| QUESTION_THREE, | ||
| NotEmptyRule(), | ||
| HasExactListRule(["Betsy", "Beth", "Daisy"], is_case_sensitive=True), | ||
| ContainsListRule( | ||
| ["Betsy", "Beth", "Daisy"], subset=True, is_case_sensitive=True | ||
| ), | ||
| ) | ||
| .add_validation( | ||
| QUESTION_FOUR, | ||
| NotEmptyRule(), | ||
| HasExactListRule(["Charlie"], is_case_sensitive=True), | ||
| ContainsListRule(["Charlie"], subset=True, is_case_sensitive=True), | ||
| ) | ||
| .validate() | ||
| ) | ||
|
|
||
| return exercise.to_output( | ||
| ["Great work in viewing and understanding the diff of a specific commit!"], | ||
| GitAutograderStatus.SUCCESSFUL, | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.