4 Commits
v8 ... v12

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
image: python:3-alpine
before_script:
- pip install pytest --no-cache-dir
script: pytest --showlocals .
- pip install pytest pytest-cov --no-cache-dir
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
"""
print("aide\t\tAffiche l'aide")
print("seminaire\tLance le séminaire")
print("blague\t\tRaconte une blague")
print("calcul\t\tVérifie une opération arithmétique. "
"Par exemple, check(1, 2, 3, '+') renvoie True")
print("tri\t\tTrie une liste d'entiers.")
print("stop\t\tQuitte le programme")
return "aide\t\tAffiche l'aide\n" \
"seminaire\tLance le séminaire\n" \
"blague\t\tRaconte une blague\n" \
"calcul\t\tVérifie une opération arithmétique. " \
"Par exemple, check(1, 2, 3, '+') renvoie True\n" \
"tri\t\tTrie une liste d'entiers.\n" \
"stop\t\tQuitte le programme"
def seminaire():

View File

@ -4,19 +4,26 @@
Exécution des tests du script.
"""
import unittest
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")
assert len(lines) == 6
assert lines[0].startswith("aide")
assert lines[1].startswith("seminaire")
assert lines[2].startswith("blague")
assert lines[3].startswith("calcul")
assert lines[4].startswith("tri")
assert lines[5].startswith("stop")
def test_aide(self):
"""
On essaie d'afficher l'aide, et on vérifie si ça affiche la bonne chose.
"""
res = main.commande("aide")
lines = res.split("\n")
self.assertEqual(len(lines), 6)
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"))