|
@@ -28,8 +28,8 @@ def _job_data(**overrides):
|
|
|
"retention_gfs_config": None,
|
|
"retention_gfs_config": None,
|
|
|
"enabled": True,
|
|
"enabled": True,
|
|
|
"core_only": False,
|
|
"core_only": False,
|
|
|
- "destination_name": None,
|
|
|
|
|
- "remote_instance_name": None,
|
|
|
|
|
|
|
+ "destination_names": [],
|
|
|
|
|
+ "remote_instance_names": [],
|
|
|
}
|
|
}
|
|
|
base.update(overrides)
|
|
base.update(overrides)
|
|
|
return base
|
|
return base
|
|
@@ -92,11 +92,11 @@ class TestExportConfig:
|
|
|
assert j["name"] == "Sys backup"
|
|
assert j["name"] == "Sys backup"
|
|
|
assert j["type"] == "ynh_system"
|
|
assert j["type"] == "ynh_system"
|
|
|
assert j["retention_value"] == 5
|
|
assert j["retention_value"] == 5
|
|
|
- assert j["destination_name"] is None
|
|
|
|
|
|
|
+ assert j["destination_names"] == []
|
|
|
|
|
|
|
|
def test_exporte_job_avec_destination(self, client, app):
|
|
def test_exporte_job_avec_destination(self, client, app):
|
|
|
with app.app_context():
|
|
with app.app_context():
|
|
|
- from db import db, Job, Destination
|
|
|
|
|
|
|
+ from db import db, Job, Destination, JobDestination
|
|
|
dest = Destination(
|
|
dest = Destination(
|
|
|
name="VPS-OVH", host="vps.example.com", port=22,
|
|
name="VPS-OVH", host="vps.example.com", port=22,
|
|
|
user="backup", remote_path="/backups", enabled=True,
|
|
user="backup", remote_path="/backups", enabled=True,
|
|
@@ -106,7 +106,8 @@ class TestExportConfig:
|
|
|
job = Job(
|
|
job = Job(
|
|
|
name="Job avec dest", type="ynh_system", config_json="{}",
|
|
name="Job avec dest", type="ynh_system", config_json="{}",
|
|
|
cron_expr="", retention_mode="count", retention_value=7,
|
|
cron_expr="", retention_mode="count", retention_value=7,
|
|
|
- enabled=True, core_only=False, destination_id=dest.id,
|
|
|
|
|
|
|
+ enabled=True, core_only=False,
|
|
|
|
|
+ job_destinations=[JobDestination(dest_type="ssh", dest_id=dest.id)],
|
|
|
)
|
|
)
|
|
|
db.session.add(job)
|
|
db.session.add(job)
|
|
|
db.session.commit()
|
|
db.session.commit()
|
|
@@ -114,7 +115,7 @@ class TestExportConfig:
|
|
|
resp = client.get("/settings/export-config")
|
|
resp = client.get("/settings/export-config")
|
|
|
data = resp.get_json()
|
|
data = resp.get_json()
|
|
|
j = data["jobs"][0]
|
|
j = data["jobs"][0]
|
|
|
- assert j["destination_name"] == "VPS-OVH"
|
|
|
|
|
|
|
+ assert j["destination_names"] == ["VPS-OVH"]
|
|
|
|
|
|
|
|
def test_nom_fichier_dans_header(self, client):
|
|
def test_nom_fichier_dans_header(self, client):
|
|
|
resp = client.get("/settings/export-config")
|
|
resp = client.get("/settings/export-config")
|
|
@@ -171,7 +172,7 @@ class TestImportConfig:
|
|
|
|
|
|
|
|
def test_lie_job_a_destination(self, client, app):
|
|
def test_lie_job_a_destination(self, client, app):
|
|
|
payload = _payload(
|
|
payload = _payload(
|
|
|
- jobs=[_job_data(destination_name="VPS-OVH")],
|
|
|
|
|
|
|
+ jobs=[_job_data(destination_names=["VPS-OVH"])],
|
|
|
destinations=[_dest_data()],
|
|
destinations=[_dest_data()],
|
|
|
)
|
|
)
|
|
|
_do_import(client, payload)
|
|
_do_import(client, payload)
|
|
@@ -180,7 +181,9 @@ class TestImportConfig:
|
|
|
from db import Job, Destination
|
|
from db import Job, Destination
|
|
|
dest = Destination.query.filter_by(name="VPS-OVH").first()
|
|
dest = Destination.query.filter_by(name="VPS-OVH").first()
|
|
|
job = Job.query.filter_by(name="Mon job").first()
|
|
job = Job.query.filter_by(name="Mon job").first()
|
|
|
- assert job.destination_id == dest.id
|
|
|
|
|
|
|
+ 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_cree_instance_distante(self, client, app):
|
|
def test_cree_instance_distante(self, client, app):
|
|
|
payload = _payload(remote_instances=[{
|
|
payload = _payload(remote_instances=[{
|