-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add tests #2813
Feat/add tests #2813
Conversation
…hange fixtures: datasets + stations
…chmy)They were replaced by Utils-Flask-SQLAlchemy and Utils-Flask-SQLAlchemy-Geo
f61a77a
to
fd85a9a
Compare
Ah mince j'avais une review en cours mais la PR était en draft et non ready for review donc j'ai attendu... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merci beaucoup pour l'ajout de tous ces tests et le début de typing !
Je passais par là donc je te fais quelques petits retours sur les tests, tu me diras !
Merci !
monkeypatch.setattr(install_module.os.path, "exists", lambda x: False) | ||
monkeypatch.setattr(install_module, "iter_modules_dist", iter_module_dist_mock("pouet")) | ||
result = cli.invoke(install_module.install_gn_module, [module_path]) | ||
assert result.exit_code > 0 # will fail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Peut-être tester un exit_code
plus précis que > 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalement, si le exit_code >0, c'est qu'il y a bien une erreur. (A mon avis) Dans ce test, faire la différence le code d'erreur à 1 et 2 n'a pas d'intérêt.
@@ -668,6 +687,40 @@ def test_get_dataset(self, users, datasets): | |||
response = self.client.get(url_for("gn_meta.get_dataset", id_dataset=ds.id_dataset)) | |||
assert response.status_code == 200 | |||
|
|||
def test_get_datasets_synthese_records_count(self, users): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il n'y a pas de fixtures datasets et synthese ici, donc ce test pourrait renvoyer une liste vide de jeux de données non ?
@@ -173,17 +276,128 @@ def test_get_releve(self, users, releve_occtax): | |||
int(releve_json["id"]) for releve_json in json_resp["items"]["features"] | |||
] | |||
|
|||
def test_post_releve(self, users, releve_data): | |||
def test_get_one_releve(self, users: dict, releve_occtax: Any): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question : pas possible de remplacer Any
par un l'objet TRelevesOccurrence
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
url_for("pr_occtax.updateReleve", id_releve=releve_occtax.id_releve_occtax), | ||
json=releve_data, | ||
) | ||
assert response.status_code == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tester le contenu de la réponse si jamais le POST renvoie l'objet créé
response = self.client.delete( | ||
url_for("pr_occtax.deleteOneReleve", id_releve=releve_occtax.id_releve_occtax) | ||
) | ||
assert response.status_code == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tester le contenu de la réponse {"message": "delete with success"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peut-être remplacer par "deleted" au passage ou par l'objet supprimé, je ne me souviens plus des bonnes pratiques là dessus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
users: dict, | ||
releve_data: dict[str, Any], | ||
module: TModules, | ||
datasets: dict[Any, TDatasets], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le Any
est un str
non ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya des int aussi
"pr_occtax.export", format="csv", id_dataset=datasets["own_dataset"].id_dataset | ||
), | ||
) | ||
assert response.status_code == 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tester le contenu du csv, pour s'assurer qu'il est bon. Il y a quelques exemples dans le module synthese je crois pour t'aider :)
As part of SQLAlchemy update to 1.4 (2.0 will be for later), we propose to improve the test of coverage for Geonature and officially supported modules.
As for now, we increase tests in :
In addition, we droped
utilssqlalchemy
andutisgeometry
(deprecated)