4 Commits

Author SHA1 Message Date
40076ad3c1 Ajout d'un README pour les badges
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 18:57:48 +01:00
60e09751da Calcul de la couverture
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 18:47:18 +01:00
1fc558a2ad On utilise une classe pour les tests
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 18:37:12 +01:00
df223bd19e La fonction d'aide renvoie le texte à afficher au lieu de l'afficher directement
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-01-26 17:45:44 +01:00
5 changed files with 33 additions and 20 deletions

BIN
.coverage Normal file

Binary file not shown.

View File

@ -25,5 +25,5 @@ test:
stage: test stage: test
image: python:3-alpine image: python:3-alpine
before_script: before_script:
- pip install pytest --no-cache-dir - pip install pytest pytest-cov --no-cache-dir
script: pytest --showlocals . script: pytest --showlocals --cov=main --cov=main_test --cov-report=term-missing .

6
README.md Normal file
View File

@ -0,0 +1,6 @@
[![pipeline status](https://gitlab.crans.org/ynerant/seminaire-ci/badges/master/pipeline.svg)](https://gitlab.crans.org/ynerant/seminaire-ci/-/commits/master)
[![coverage report](https://gitlab.crans.org/ynerant/seminaire-ci/badges/master/coverage.svg)](https://gitlab.crans.org/ynerant/seminaire-ci/-/commits/master)
# Séminaire intégration continue
Ce dépôt contient le script utilisé lors du séminaire Crans du 11 février 2021, ainsi que les slides.

14
main.py
View File

@ -38,13 +38,13 @@ def aide():
""" """
Affiche l'aide Affiche l'aide
""" """
print("aide\t\tAffiche l'aide") return "aide\t\tAffiche l'aide\n" \
print("seminaire\tLance le séminaire") "seminaire\tLance le séminaire\n" \
print("blague\t\tRaconte une blague") "blague\t\tRaconte une blague\n" \
print("calcul\t\tVérifie une opération arithmétique. " "calcul\t\tVérifie une opération arithmétique. " \
"Par exemple, check(1, 2, 3, '+') renvoie True") "Par exemple, check(1, 2, 3, '+') renvoie True\n" \
print("tri\t\tTrie une liste d'entiers.") "tri\t\tTrie une liste d'entiers.\n" \
print("stop\t\tQuitte le programme") "stop\t\tQuitte le programme"
def seminaire(): def seminaire():

View File

@ -4,19 +4,26 @@
Exécution des tests du script. Exécution des tests du script.
""" """
import unittest
import main import main
def test_aide(): class TestMain(unittest.TestCase):
""" """
On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose. Cette classe permet d'executer l'ensemble des scripts
""" """
res = main.commande("aide")
lines = res.split("\n") def test_aide(self):
assert len(lines) == 6 """
assert lines[0].startswith("aide") On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose.
assert lines[1].startswith("seminaire") """
assert lines[2].startswith("blague") res = main.commande("aide")
assert lines[3].startswith("calcul") lines = res.split("\n")
assert lines[4].startswith("tri") self.assertEqual(len(lines), 6)
assert lines[5].startswith("stop") self.assertTrue(lines[0].startswith("aide"))
self.assertTrue(lines[1].startswith("seminaire"))
self.assertTrue(lines[2].startswith("blague"))
self.assertTrue(lines[3].startswith("calcul"))
self.assertTrue(lines[4].startswith("tri"))
self.assertTrue(lines[5].startswith("stop"))