-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
3,225 additions
and
35 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
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
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
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,3 @@ | ||
[default.extend-words] | ||
# German Adresse | ||
Adresse = "Adresse" |
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
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
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
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 @@ | ||
../../install.sh |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[run] | ||
omit = | ||
**/test/* | ||
**/tests/* | ||
**/__init__.py |
Empty file.
Empty file.
Empty file.
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 @@ | ||
"""Empty test module.""" |
20 changes: 20 additions & 0 deletions
20
tools/tests/code_evaluation/jobs/modules/factory_test_module.py
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,20 @@ | ||
"""Test module.""" | ||
|
||
from sel_tools.code_evaluation.jobs.common import EvaluationJob | ||
from sel_tools.code_evaluation.jobs.factory import EvaluationJobFactory | ||
from sel_tools.utils.repo import GitlabProject | ||
from tests.helper import SimplePassingJob | ||
|
||
|
||
class TestFactory(EvaluationJobFactory): | ||
"""Test factory.""" | ||
|
||
@staticmethod | ||
def create( | ||
gitlab_projects: list[GitlabProject], homework_number: int | ||
) -> list[EvaluationJob]: | ||
evaluation_map: dict[int, list[EvaluationJob]] = { | ||
1: [], | ||
2: [SimplePassingJob()], | ||
} | ||
return evaluation_map[homework_number] |
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,74 @@ | ||
"""Common code evaluation job test.""" | ||
|
||
import unittest | ||
from pathlib import Path | ||
from subprocess import CalledProcessError | ||
from unittest.mock import MagicMock, patch | ||
|
||
from pyfakefs.fake_filesystem_unittest import TestCase | ||
from sel_tools.code_evaluation.jobs.common import ( | ||
run_shell_command, | ||
run_shell_command_with_output, | ||
) | ||
from sel_tools.code_evaluation.report import EvaluationResult | ||
from tests.helper import ComplexJob, SimpleFailingJob, SimplePassingJob | ||
|
||
|
||
class EvaluationJobTest(unittest.TestCase): | ||
"""Evaluation job test.""" | ||
|
||
def test_simple_failing_job(self) -> None: | ||
unit = SimpleFailingJob() | ||
results = unit.run(Path()) | ||
self.assertListEqual( | ||
[EvaluationResult("simple_fail", 0, "This caused the fail")], results | ||
) | ||
|
||
def test_simple_passing_job(self) -> None: | ||
unit = SimplePassingJob() | ||
results = unit.run(Path()) | ||
self.assertListEqual([EvaluationResult("simple_pass", 1)], results) | ||
|
||
def test_simple_passing_job_with_weight(self) -> None: | ||
unit = SimplePassingJob(3) | ||
results = unit.run(Path()) | ||
self.assertListEqual([EvaluationResult("simple_pass", 3)], results) | ||
|
||
def test_complex_job(self) -> None: | ||
unit = ComplexJob() | ||
results = unit.run(Path()) | ||
self.assertListEqual( | ||
[ | ||
EvaluationResult("simple_fail", 0, "This caused the fail"), | ||
EvaluationResult("simple_pass", 2), | ||
EvaluationResult("complex", 3), | ||
], | ||
results, | ||
) | ||
|
||
|
||
class JobsTest(TestCase): | ||
"""Test for jobs module.""" | ||
|
||
@patch("subprocess.check_call", MagicMock(return_value=0)) | ||
def test_run_shell_command_success(self) -> None: | ||
result = run_shell_command("make", Path()) | ||
self.assertEqual(1, result) | ||
|
||
@patch("subprocess.check_call", MagicMock(side_effect=CalledProcessError(2, ""))) | ||
def test_run_shell_command_fail(self) -> None: | ||
result = run_shell_command("make", Path()) | ||
self.assertEqual(0, result) | ||
|
||
@patch("subprocess.check_output", MagicMock(return_value=b"success")) | ||
def test_run_shell_command_with_output_success(self) -> None: | ||
result = run_shell_command_with_output("make", Path()) | ||
self.assertEqual((1, "success"), result) | ||
|
||
@patch( | ||
"subprocess.check_output", | ||
MagicMock(side_effect=CalledProcessError(2, "", output=b"fail")), | ||
) | ||
def test_run_shell_command_with_output_fail(self) -> None: | ||
result = run_shell_command_with_output("make", Path()) | ||
self.assertEqual((0, "fail"), result) |
Oops, something went wrong.