Skip to content

Conversation

@SolalPirelli
Copy link
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

"""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
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

def names(self):
"""Obtient la liste des noms, en anglais, des objets disponibles"""
result = []
for _, planet in self.values.items():
Copy link
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():


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
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 ?

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
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


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
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 ?

class LocalDatabaseModelTests(TestCase):
def test_names(self):
m = LocalDatabaseModel()
self.assertIn("Sextans Dwarf Spheroidal Galaxy", m.names())
Copy link
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 ?

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
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

@@ -0,0 +1,9 @@
class ConsoleView:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documentation ?

self._show_list(self.model.names())
return

parts = command.split(' ')
Copy link
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(' ')

self._show_list(self.model.translated_names(parts[1]))
return

self.view.show("Commande inconnue")
Copy link
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.

2 participants