Skip to content

Exercice 2 : Revue de revue#1

Open
SolalPirelli wants to merge 1 commit into
mainfrom
pr2
Open

Exercice 2 : Revue de revue#1
SolalPirelli wants to merge 1 commit into
mainfrom
pr2

Conversation

@SolalPirelli
Copy link
Copy Markdown
Contributor

@SolalPirelli SolalPirelli commented Nov 16, 2025

Quels commentaires sont utiles ? Lesquels ne le sont pas ? Manque-t-il des commentaires ?

Ouvrez l'onglet "Files changed" pour commencer

Comment thread model.py
"""Modèle utilisant une base de donnée locale en JSON"""
def __init__(self):
# `utf-8` pour être sûr que le fichier est lu correctement quel que soit l'OS
with open("dsonames.json", "r+", encoding="utf-8") as f:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ouvrir le fichier avec la permission r+, qui signifie lecture + écriture ? r, lecture seule, devrait être suffisant

Comment thread model.py
def names(self):
"""Obtient la liste des noms, en anglais, des objets disponibles"""
result = []
for _, planet in self.values.items():
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, planet in self.values.items():
for planet in self.values.values():

Comment thread model.py

def translated_names(self, language):
"""Obtient une correspondance entre noms et noms traduits dans la langue donnée."""
return [(p["name"], p[language]) for p in self.values.values() if language in p]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce normal que certaines planètes n'ont pas de nom traduit ? Devrions-nous le documenter ?

Comment thread presenter.py
def __init__(self, model, view):
"""Crée un Presenter avec un modèle et une view donnés."""
self.model = model
self.view = view
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_model et _view puisque ce sont des champs privés

Comment thread presenter.py

def _show_list(self, lst):
"""Affiche la liste donnée via la view."""
self.view.show("\n".join(["- " + str(s) for s in lst]))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plutôt "* " pour une liste à puces, non ?

Comment thread tests.py
class LocalDatabaseModelTests(TestCase):
def test_names(self):
m = LocalDatabaseModel()
self.assertIn("Sextans Dwarf Spheroidal Galaxy", m.names())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devrions-nous tester l'ordre des planètes ?

Comment thread tests.py
p = Presenter(FakeModel(), v)
self.assertEqual([], v.outputs)
p.run()
self.assertEqual(["Bonjour! Cette application vous donne des informations sur les groupes d'étoiles.", "- X\n- Y\n- Z"], v.outputs)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il existe des méthodes plus spécialisées que assertEqual, elles seraient utiles au cas où les tests échouent pour avoir des messages d'erreur plus clair

Comment thread view.py
@@ -0,0 +1,9 @@
class ConsoleView:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation ?

Comment thread presenter.py
self._show_list(self.model.names())
return

parts = command.split(' ')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parts = command.split(' ')
chunks = command.split(' ')

Comment thread presenter.py
self._show_list(self.model.translated_names(parts[1]))
return

self.view.show("Commande inconnue")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas génial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant