Refactor all tests to use put_config_dicts
Description
And then remove the implementation for put_config_dict. Sometimes tests set the hostname, that is not needed with put_config_dicts, if a hostname setting exist, remove it as well. (of course not when testing hostname changes :))
this is not a search and replace job, you need to identify the intention of each test, so test coverage is not lost. But where applicable, send multiple models in the same query e.g, from ospf_multiarea:
def config_target4(target, ring1, cross, link):
target.put_config_dicts({
"ietf-interfaces": {
"interfaces": {
"interface": [
{
"name": ring1,
"enabled": True,
"ipv4": {
"forwarding": True,
"address": [{
"ip": "10.0.41.1",
"prefix-length": 30
}]}
},
{
"name": cross,
"enabled": True,
"ipv4": {
"forwarding": True,
"address": [{
"ip": "10.0.24.2",
"prefix-length": 30
}]}
},
{
"name": link,
"enabled": True,
"ipv4": {
"forwarding": True,
"address": [{
"ip": "192.168.4.1",
"prefix-length": 24
}]
}
},
{
"name": "lo",
"enabled": True,
"ipv4": {
"address": [{
"ip": "10.0.0.4",
"prefix-length": 32
}]
}
}
]
}
},
"ietf-routing": {
"routing": {
"control-plane-protocols": {
"control-plane-protocol": [
{
"type": "infix-routing:ospfv2",
"name": "default",
"ospf": {
"explicit-router-id": "10.0.0.4",
"redistribute": {
"redistribute": [{
"protocol": "connected"
}]
},
"areas": {
"area": [{
"area-id": "0.0.0.2",
"interfaces": {
"interface": [{
"bfd": {
"enabled": True
},
"name": ring1,
"hello-interval": 1,
"enabled": True,
"interface-type": "point-to-point"
}, {
"bfd": {
"enabled": True
},
"name": cross,
"hello-interval": 1,
"enabled": True,
"cost": 5000
}, {
"name": "lo",
"enabled": True
}]
}
}]
}
}
}
]
}
}
}
})
Additional Information
No response
General Information
Anyone can help out by sponsoring development of new features or contributing pull requests. Please use this issue for discussions related to the feature.
Thanks for the clarification at the end, @mattiaswal, that one is crucial since sometimes there's a point to a split. I even had one test that relied on the timing so I put timing critical stuff in my first call to put_config_dict() — that is of course very evil, but I wouldn't be surprised if a PR for this uncovered some unintentional timing issues at least.
Thankfully put_config_dicts() is a perfect superset of put_config_dict() so I'd even propose renaming the final result back to put_config_dict() and documenting the behavior properly.