|
|
@@ -243,3 +243,40 @@ class TestImportConfig:
|
|
|
def test_sans_fichier_redirige(self, client):
|
|
|
resp = client.post("/settings/import-config", data={})
|
|
|
assert resp.status_code == 302
|
|
|
+
|
|
|
+ def test_compat_ancien_format_destination_name(self, client, app):
|
|
|
+ """Ancien format destination_name (singulier) doit être reconnu à l'import."""
|
|
|
+ payload = _payload(
|
|
|
+ jobs=[_job_data(destination_name="VPS-OVH")],
|
|
|
+ destinations=[_dest_data()],
|
|
|
+ )
|
|
|
+ # Supprimer les clés du nouveau format pour simuler un vieux fichier
|
|
|
+ payload["jobs"][0].pop("destination_names", None)
|
|
|
+ payload["jobs"][0].pop("remote_instance_names", None)
|
|
|
+ _do_import(client, payload)
|
|
|
+
|
|
|
+ with app.app_context():
|
|
|
+ from db import Job, Destination
|
|
|
+ dest = Destination.query.filter_by(name="VPS-OVH").first()
|
|
|
+ job = Job.query.filter_by(name="Mon job").first()
|
|
|
+ assert len(job.job_destinations) == 1
|
|
|
+ assert job.job_destinations[0].dest_type == "ssh"
|
|
|
+ assert job.job_destinations[0].dest_id == dest.id
|
|
|
+
|
|
|
+ def test_compat_ancien_format_remote_instance_name(self, client, app):
|
|
|
+ """Ancien format remote_instance_name (singulier) doit être reconnu à l'import."""
|
|
|
+ payload = _payload(
|
|
|
+ jobs=[_job_data(remote_instance_name="Tom")],
|
|
|
+ remote_instances=[{"name": "Tom", "url": "https://tom.example.com", "api_key": "k"}],
|
|
|
+ )
|
|
|
+ payload["jobs"][0].pop("destination_names", None)
|
|
|
+ payload["jobs"][0].pop("remote_instance_names", None)
|
|
|
+ _do_import(client, payload)
|
|
|
+
|
|
|
+ with app.app_context():
|
|
|
+ from db import Job, RemoteInstance
|
|
|
+ inst = RemoteInstance.query.filter_by(name="Tom").first()
|
|
|
+ job = Job.query.filter_by(name="Mon job").first()
|
|
|
+ assert len(job.job_destinations) == 1
|
|
|
+ assert job.job_destinations[0].dest_type == "instance"
|
|
|
+ assert job.job_destinations[0].dest_id == inst.id
|