tests for notes_tools

This commit is contained in:
Benjamin Bertrand
2016-11-13 15:35:44 +03:00
parent ec469214da
commit 5e8c955867
9 changed files with 114 additions and 37 deletions

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env python
# encoding: utf-8
from notes_tools import df_marks_manip
# TODO: faire des tests unitaire |mar. nov. 8 11:20:57 EAT 2016
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python
# encoding: utf-8
from notes_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