From 3876b026266fa46d3d4b4dc8a0ae4b2785ad1e65 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 20 Jul 2021 18:27:54 +0300 Subject: [PATCH] reorganized unit tests and fixed bug in cache handling --- tests/unit/test_caches.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/unit/test_caches.py diff --git a/tests/unit/test_caches.py b/tests/unit/test_caches.py new file mode 100644 index 000000000..2b06f1486 --- /dev/null +++ b/tests/unit/test_caches.py @@ -0,0 +1,31 @@ +# -*- coding: UTF-8 -* + +"""Unit tests for caches + + +Ce test suppose une base département existante. + +Usage: pytest tests/unit/test_caches.py +""" + + +from flask import current_app + +from app import db +from app.scodoc import sco_cache +from app.scodoc import sco_formsemestre + +DEPT = "RT" # ce département (BD) doit exister + + +def test_notes_table(test_client): + """Test construction et cache de NotesTable""" + sems = sco_formsemestre.do_formsemestre_list(None) + assert len(sems) + sem = sems[0] + formsemestre_id = sem["formsemestre_id"] + nt = sco_cache.NotesTableCache.get(formsemestre_id) + assert nt + assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False) + sco_cache.invalidate_formsemestre(formsemestre_id) + assert not sco_cache.NotesTableCache.get(formsemestre_id, compute=False)