Skip to content

Commit

Permalink
Add basic test for the assess_min_commits plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nunofachada committed Feb 25, 2024
1 parent c4cee7f commit 8837bec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/conftest.py
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
1 change: 1 addition & 0 deletions tests/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Plugin tests."""
26 changes: 26 additions & 0 deletions tests/plugins/test_repo.py
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

0 comments on commit 8837bec

Please sign in to comment.