repytex/notes_tools/test/test_df_marks_manip.py

63 lines
1.8 KiB
Python

#!/usr/bin/env python
# encoding: utf-8
from notes_tools import df_marks_manip
import pandas
def test_round_half_point():
assert df_marks_manip.round_half_point(2) == 2
assert df_marks_manip.round_half_point(2.1) == 2.5
assert df_marks_manip.round_half_point(2.4) == 2.5
assert df_marks_manip.round_half_point(2.6) == 3
assert df_marks_manip.round_half_point(2.9) == 3
assert df_marks_manip.round_half_point(pandas.np.nan)
def test_note_to_rep():
d = {"Niveau": 1, "Note": 0}
assert df_marks_manip.note_to_rep(d) == "\\RepZ"
d = {"Niveau": 1, "Note": 1}
assert df_marks_manip.note_to_rep(d) == "\\RepU"
d = {"Niveau": 1, "Note": 2}
assert df_marks_manip.note_to_rep(d) == "\\RepD"
d = {"Niveau": 1, "Note": 3}
assert df_marks_manip.note_to_rep(d) == "\\RepT"
d = {"Niveau": 1, "Note": None}
assert df_marks_manip.note_to_rep(d) == "\\NoRep"
d = {"Niveau": 1, "Note": pandas.np.nan}
assert df_marks_manip.note_to_rep(d) == "\\NoRep"
d = {"Niveau": 0, "Note": "plop"}
assert df_marks_manip.note_to_rep(d) == "plop"
d = {"Niveau": 0, "Note": 1}
assert df_marks_manip.note_to_rep(d) == 1
def test_note_to_mark():
d = {"Niveau": 1, "Note": 0, "Bareme": 6}
assert df_marks_manip.note_to_mark(d) == 6/3*0
d = {"Niveau": 1, "Note": 1, "Bareme": 6}
assert df_marks_manip.note_to_mark(d) == 6/3*1
d = {"Niveau": 1, "Note": 2, "Bareme": 6}
assert df_marks_manip.note_to_mark(d) == 6/3*2
d = {"Niveau": 1, "Note": 3, "Bareme": 6}
assert df_marks_manip.note_to_mark(d) == 6/3*3
d = {"Niveau": 0, "Note": 3, "Bareme": 6}
assert df_marks_manip.note_to_mark(d) == 3
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del