Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
INF-TC2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Derrode Stéphane
INF-TC2
Commits
2c3be372
Commit
2c3be372
authored
4 years ago
by
Derrode Stéphane
Browse files
Options
Downloads
Patches
Plain Diff
BE #1 - add crash-test dans BE #1
parent
771077cb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
seance1_4h/crash_test_biblio.py
+67
-0
67 additions, 0 deletions
seance1_4h/crash_test_biblio.py
with
67 additions
and
0 deletions
seance1_4h/crash_test_biblio.py
0 → 100644
+
67
−
0
View file @
2c3be372
from
Bibliotheque
import
Bibliotheque
from
Lecteur
import
Lecteur
if
__name__
==
'
__main__
'
:
# Création d'une bibliothèque
MS
=
Bibliotheque
(
'
Michel Serre
'
)
print
(
"
MS =
"
,
MS
)
# Affichage attendu : "MS = Nom de la biblio : Michel Serre"
print
(
"
b1 =
"
,
Bibliotheque
(
1
))
# Affichage attendu : "b1 = Nom de la biblio : 1"
print
(
'
\n
==>test bibliothèque vide
'
)
# Recherches
print
(
MS
.
chercher_lecteur_numero
(
1
))
# Affichage attendu : None
print
(
MS
.
chercher_livre_numero
(
1
))
# Affichage attendu : None
print
(
MS
.
chercher_lecteur_nom
(
'
Levgueni Dimitri
'
))
# Affichage attendu : None
print
(
MS
.
chercher_livre_titre
(
'
Les Hauts de Hurlevent
'
))
# Affichage attendu : None
# Affichage
MS
.
affiche_livres
()
# Affichage attendu : (rien)
MS
.
affiche_lecteurs
()
# Affichage attendu : (rien)
MS
.
affiche_emprunts
()
# Affichage attendu : (rien)
print
(
'
\n
==>test bibliothèque non vide mais sans emprunt
'
)
MS
.
ajout_lecteur
(
Lecteur
(
'
Mzai Ahmed
'
,
'
Boulevard de la Paix
'
,
1
))
MS
.
ajout_lecteur
(
Lecteur
(
'
Xu John
'
,
'
Rue de la Gare
'
,
2
))
MS
.
ajout_livre
(
'
Le Père Goriot
'
,
'
Honoré de Balzac
'
,
-
1
,
101
)
MS
.
ajout_livre
(
"
Léon l
'
Africain
"
,
'
Amin Maalouf
'
,
2
,
102
)
MS
.
affiche_livres
()
# Affichage attendu : le premier livre doit afficher 0 exemplaire (et non -1!)
MS
.
affiche_lecteurs
()
# Affichage attendu : les 2 lecteurs
MS
.
affiche_emprunts
()
# Affichage attendu : (rien)
print
(
MS
.
chercher_lecteur_numero
(
1
))
# Affichage attendu : le lecteur Mzai Ahmed
print
(
MS
.
chercher_livre_numero
(
1
))
# Affichage attendu : None
print
(
MS
.
chercher_livre_numero
(
102
))
# Affichage attendu : le livre Léon L'Africain
print
(
MS
.
chercher_lecteur_nom
(
'
Xu John
'
))
# Affichage attendu : le lecteur Xu John
print
(
MS
.
chercher_livre_titre
(
'
Samarcande
'
))
# Affichage attendu : None
print
(
'
\n
==>test bibliothèque non vide et avec emprunt
'
)
MS
.
emprunt_livre
(
8
,
101
)
# Affichage attendu : Emprunt impossible : lecteur inexistant (car 0 livre dispo)
MS
.
emprunt_livre
(
1
,
1001
)
# Affichage attendu : Emprunt impossible : livre inexistant (car 0 livre dispo)
MS
.
emprunt_livre
(
1
,
101
)
# Affichage attendu : Emprunt impossible (car 0 livre dispo)
MS
.
emprunt_livre
(
1
,
102
)
# Affichage attendu : (rien) (car l'emprunt est OK)
MS
.
affiche_emprunts
()
# Affichage attendu : Emprunt - Numero lecteur : 1, Numero livre: 102, Date : 2021-xx-yy
MS
.
retour_livre
(
33
,
102
)
# Affichage attendu : Aucun emprunt ne correspond a ces informations : 33 102
MS
.
retour_livre
(
1
,
102
)
# Affichage attendu : (rien) (le livre emprunté a bien été rendu)
MS
.
affiche_emprunts
()
# Affichage attendu : (rien) (car il n'y a aucun livre emprunté)
print
(
MS
.
retrait_livre
(
28
))
# Affichage attendu : False
print
(
MS
.
retrait_livre
(
101
))
# Affichage attendu : False (car il n'y a aucun exemplaire de ce livre)
MS
.
emprunt_livre
(
1
,
102
)
print
(
MS
.
retrait_livre
(
102
))
# Affichage attendu : False car le livre est emprunté
MS
.
retour_livre
(
1
,
102
)
print
(
MS
.
retrait_livre
(
102
))
# Affichage attendu : True
print
(
MS
.
retrait_lecteur
(
28
))
# Affichage attendu : False
MS
.
ajout_livre
(
"
Léon l
'
Africain
"
,
'
Amin Maalouf
'
,
2
,
102
)
MS
.
emprunt_livre
(
1
,
102
)
print
(
MS
.
retrait_lecteur
(
1
))
# Affichage attendu : False (car emprunt en cours)
MS
.
retour_livre
(
1
,
102
)
print
(
MS
.
retrait_lecteur
(
1
))
# Affichage attendu : True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment