reorga files
This commit is contained in:
62
notes_tools/tools/test/test_df_marks_manip.py
Normal file
62
notes_tools/tools/test/test_df_marks_manip.py
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
from notes_tools.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
|
59
notes_tools/tools/test/test_extract.py
Normal file
59
notes_tools/tools/test/test_extract.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
from notes_tools.tools import extract
|
||||
import pandas
|
||||
import pytest
|
||||
|
||||
|
||||
sample_path = "./samples/"
|
||||
|
||||
def test_list_classes():
|
||||
clss = extract.list_classes(sample_path)
|
||||
assert clss == ["503", "312", "308"]
|
||||
|
||||
def test_get_class_ws_raise():
|
||||
with pytest.raises(Exception) as e_info:
|
||||
extract.get_class_ws("312")
|
||||
|
||||
def test_parse_sheets():
|
||||
ws = extract.get_class_ws("312", sample_path)
|
||||
sheets = extract.parse_sheets(ws)
|
||||
assert len(sheets) == 2
|
||||
assert type(sheets[0]) == pandas.core.frame.DataFrame
|
||||
|
||||
def test_extract_students():
|
||||
ws = extract.get_class_ws("312", sample_path)
|
||||
sheets = extract.parse_sheets(ws)
|
||||
students = extract.extract_students(sheets[0])
|
||||
_students = pandas.Index(['Eleve 1', 'Eleve 10', 'Eleve 2', 'Eleve 3', 'Eleve 4', 'Eleve 5', 'Eleve 6', 'Eleve 7', 'Eleve 8', 'Eleve 9'], dtype='object')
|
||||
assert list(students) == list(_students)
|
||||
|
||||
def test_check_students():
|
||||
ws = extract.get_class_ws("312", sample_path)
|
||||
sheets = extract.parse_sheets(ws)
|
||||
students = extract.check_students(sheets)
|
||||
_students = pandas.Index(['Eleve 1', 'Eleve 10', 'Eleve 2', 'Eleve 3', 'Eleve 4', 'Eleve 5', 'Eleve 6', 'Eleve 7', 'Eleve 8', 'Eleve 9'], dtype='object')
|
||||
assert list(students) == list(_students)
|
||||
|
||||
|
||||
ws = extract.get_class_ws("308", sample_path)
|
||||
sheets = extract.parse_sheets(ws)
|
||||
with pytest.raises(Exception) as e_info:
|
||||
students = extract.check_students(sheets)
|
||||
|
||||
def test_flat_df_students():
|
||||
ws = extract.get_class_ws("312", sample_path)
|
||||
sheets = extract.parse_sheets(ws)
|
||||
students = extract.check_students(sheets)
|
||||
|
||||
# Sheets[1] is the sheet Connaissances
|
||||
flat_df = extract.flat_df_students(sheets[1], students)
|
||||
assert len(flat_df) == 80
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
Reference in New Issue
Block a user