repytex/notes_tools/tools/test/test_extract.py

60 lines
1.9 KiB
Python
Raw Normal View History

2016-11-13 12:35:44 +00:00
#!/usr/bin/env python
# encoding: utf-8
2016-11-13 15:54:11 +00:00
from notes_tools.tools import extract
import pandas
2016-11-13 12:35:44 +00:00
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