écrit moi un prompt pour que mon github copilot, il me créer un projet.
Ce Projet c'est des tests automatisé d'apis avec robot framework.
Le but est que je fais des apelles api avec un parametre "FORCE" avec la valeur "0", si j'ai un code autre que 200 je passe le parametre "FORCE" en "1".
Après avoir recu le code 200, je dois controlé les données dans le respons body.
Les controle consiste a comparé les valeurs des champs dans le respons body avec ce qu'il y a dans la base mongo.Mais attention la structure n'est pas la mm entre les 2 json on peut avoir un champs avec un chemin différent sur les 2 json mais ce sont les mm donées. Tu dois prendre un fichier yml qui contient le mapping des champs
ex :
synthetic_information:
consumer_free_text: PERSONNE.REFINT
LEI_number: PERSONNE.LEI
new_registration_number: PERSONNE.IDNOUV
contact:
BDF_branch_office: PERSONNE.LIEU.CPMAJ
postal_address:
street_address_line: PERSONNE.LIEU.ADRESS
town_or_country_location: PERSONNE.LIEU.LOCALI
phone_number: PERSONNE.LIEU.TELEPH
BDF_ENTMORT:
BDF_code: PERSONNE.ENTMORT.CREE
BDF_label: PERSONNE.ENTMORT.CREE
J'ai déja le code pour faire la requet sur mongo donc pas besoin de le dev
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
## Core Logic to implement
### Step 1 - API Call with FORCE parameter
- Make an HTTP API call with parameter `FORCE=0`
- If response code is NOT 200, retry the same call with `FORCE=1`
- Continue only when response code is 200
- Use RequestsLibrary for HTTP calls
### Step 2 - Response Body Validation against MongoDB
- After receiving HTTP 200, extract the response body (JSON)
- Fetch the corresponding document from MongoDB (MongoLibrary already exists)
- Load the field mapping from a YAML file
- Compare field values between API response and MongoDB document using the mapping
## Field Mapping YAML Structure (field_mapping.yml)
The YAML defines how fields in the API response map to fields in MongoDB.
The structure can be nested on the API side but flat with dot notation on the Mongo side.
Example of field_mapping.yml:
```yaml
synthetic_information:
consumer_free_text: PERSONNE.REFINT
LEI_number: PERSONNE.LEI
new_registration_number: PERSONNE.IDNOUV
contact:
BDF_branch_office: PERSONNE.LIEU.CPMAJ
postal_address:
street_address_line: PERSONNE.LIEU.ADRESS
town_or_country_location: PERSONNE.LIEU.LOCALI
phone_number: PERSONNE.LIEU.TELEPH
BDF_ENTMORT:
BDF_code: PERSONNE.ENTMORT.CREE
BDF_label: PERSONNE.ENTMORT.CREE
Python Library: YamlMappingParser.py
Create a Python class YamlMappingParser with:
Method load_mapping(yaml_file_path): loads the YAML file and returns a flat dictionary
where key = dot-notation path in API response JSON (e.g., "synthetic_information.contact.postal_address.street_address_line")
and value = dot-notation path in MongoDB document (e.g., "PERSONNE.LIEU.ADRESS")
Method get_value_from_json(json_dict, dot_path): navigates a nested JSON/dict using a dot-notation path and returns the value
Handle the case where a field path does not exist in JSON (return None and log a warning)
Generate a clear failure message listing ALL mismatches at once, not one by one
code
---
## Comment utiliser ce prompt ?
1. **Ouvre GitHub Copilot Chat** dans VS Code
2. **Colle le prompt** tel quel
3. Tu peux ensuite affiner avec des questions complémentaires comme :
- *"Can you add error handling if the API is unreachable?"*
- *"Add a second test case for a list of document IDs read from a CSV file"*
Veux-tu que j'ajoute des précisions, par exemple sur **l'authentification API**, le **type de requête (GET/POST)**, ou la **structure exacte de ta MongoLibrary** ?