From 60573eaa04898b893155d9dd44aa1459acd142b8 Mon Sep 17 00:00:00 2001 From: Florian Aucomte <33633200+faucomte97@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:33:23 +0100 Subject: [PATCH] fix: Add attempt creation test util (#1241) * fix: Add attempt creation test util * Add test files to codecov ignore list * Fix codecov.yml --- .codecov.yml | 6 ++++-- game/tests/utils/attempt.py | 8 ++++++++ game/tests/utils/level.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 game/tests/utils/attempt.py diff --git a/.codecov.yml b/.codecov.yml index 5a4970874..9a8f2cfdb 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -9,7 +9,9 @@ comment: require_changes: false require_base: no require_head: yes - branches: !master + branches: + - "!master" ignore: - - "game/tests/*" + - "game/tests/*.py" + - "game/tests/**/*.py" diff --git a/game/tests/utils/attempt.py b/game/tests/utils/attempt.py new file mode 100644 index 000000000..f35835aa3 --- /dev/null +++ b/game/tests/utils/attempt.py @@ -0,0 +1,8 @@ +from game.models import Attempt + + +def create_attempt(student, level, score): + attempt = Attempt(level=level, student=student, score=score, is_best_attempt=True) + attempt.save() + + return attempt diff --git a/game/tests/utils/level.py b/game/tests/utils/level.py index d37289103..296ded58e 100644 --- a/game/tests/utils/level.py +++ b/game/tests/utils/level.py @@ -25,7 +25,7 @@ def create_save_level(teacher): "destinations": "[[3,4]]", } level = Level(default=False, anonymous=data["anonymous"]) - level.owner = teacher.user.user.userprofile + level.owner = teacher.user level_management.save_level(level, data) level.save()