Skip to content
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

Merged
merged 9 commits into from
Dec 5, 2023
Merged

Feat/add tests #2813

merged 9 commits into from
Dec 5, 2023

Conversation

jacquesfize
Copy link
Contributor

@jacquesfize jacquesfize commented Dec 1, 2023

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 :

  • Occhab
  • Occtax
  • Command Lines
  • metadata
  • MTD sync
  • Geonature utils

In addition, we droped utilssqlalchemy and utisgeometry (deprecated)

@Pierre-Narcisi Pierre-Narcisi marked this pull request as ready for review December 5, 2023 13:13
@Pierre-Narcisi Pierre-Narcisi merged commit f6336c5 into feat/update-dependencies Dec 5, 2023
@Pierre-Narcisi Pierre-Narcisi deleted the feat/add-tests branch December 5, 2023 13:24
@mvergez
Copy link
Contributor

mvergez commented Dec 5, 2023

Ah mince j'avais une review en cours mais la PR était en draft et non ready for review donc j'ai attendu...
Je vous l'envoie quand même vous me direz !

Copy link
Contributor

@mvergez mvergez left a 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
Copy link
Contributor

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 ?

Copy link
Contributor Author

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):
Copy link
Contributor

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):
Copy link
Contributor

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 ?

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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],
Copy link
Contributor

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 ?

Copy link
Contributor

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
Copy link
Contributor

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

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.

3 participants