-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic test for the assess_min_commits plugin
- Loading branch information
1 parent
c4cee7f
commit 8837bec
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,8 @@ | ||
import pytest | ||
from egrader.git import git_at | ||
|
||
|
||
@pytest.fixture | ||
def git_repo_empty(tmp_path): | ||
git_at(tmp_path, "init") | ||
return tmp_path |
This file contains 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 @@ | ||
"""Plugin tests.""" |
This file contains 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,26 @@ | ||
from pathlib import Path | ||
from egrader.git import git_at | ||
from egrader.types import StudentGit | ||
from egrader.plugins.repo import assess_min_commits | ||
|
||
def do_tmpfile_commit(tmp_file_path: Path): | ||
with open(tmp_file_path, 'a') as tmp_file: | ||
tmp_file.write('Some more text') | ||
git_at(tmp_file_path.parent, "add", tmp_file_path.name) | ||
git_at(tmp_file_path.parent, 'commit', '-m', '"Yet another commit"') | ||
|
||
def test_repo_assess_min_commits_no(git_repo_empty): | ||
some_file_path = Path(git_repo_empty, 'some_file.txt') | ||
do_tmpfile_commit(some_file_path) | ||
stdgit = StudentGit('', '', '') | ||
result = assess_min_commits(stdgit, str(git_repo_empty), 2) | ||
assert result == 0 | ||
|
||
def test_repo_assess_min_commits_yes(git_repo_empty): | ||
some_file_path = Path(git_repo_empty, 'some_file.txt') | ||
do_tmpfile_commit(some_file_path) | ||
do_tmpfile_commit(some_file_path) | ||
do_tmpfile_commit(some_file_path) | ||
stdgit = StudentGit('', '', '') | ||
result = assess_min_commits(stdgit, str(git_repo_empty), 2) | ||
assert result == 1 |