add test about deepcopy with multi parents

This commit is contained in:
Emmanuel Garette 2021-04-03 20:38:08 +02:00
parent f7721a9775
commit 87093da974
2 changed files with 33 additions and 1 deletions

View File

@ -268,7 +268,6 @@ async def test_prop_dyndescription_force_store_value():
@pytest.mark.asyncio
async def test_prop_dyndescription_force_store_value_calculation_prefix():
print()
lst = StrOption('lst', '', ['val1', 'val2'], multi=True)
st = StrOption('st', '', Calculation(return_list, Params(ParamSuffix())) , properties=('force_store_value',))
dod = DynOptionDescription('dod', '', [st], suffixes=Calculation(return_list, Params(ParamOption(lst))))

View File

@ -1130,6 +1130,39 @@ async def test_meta_properties_meta_deepcopy():
await delete_sessions([meta, meta2])
@pytest.mark.asyncio
async def test_meta_properties_meta_deepcopy_multi_parent():
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
conf1 = await Config(interface1, session_id='conf1')
conf2 = await Config(interface1, session_id='conf2')
await conf1.property.read_write()
await conf2.property.read_write()
meta1 = await MetaConfig([conf1, conf2], session_id='meta1')
await meta1.permissive.add('hidden')
await meta1.property.read_write()
meta2 = await MetaConfig(['name1', 'name2'], optiondescription=interface1, session_id='meta2')
await meta2.config.add(conf1)
await meta1.option('ip_admin_eth0').value.set('192.168.1.1')
await meta2.option('netmask_admin_eth0').value.set('255.255.255.0')
assert await meta1.value.dict() == {'ip_admin_eth0': '192.168.1.1', 'netmask_admin_eth0': None}
assert await meta2.value.dict() == {'ip_admin_eth0': None, 'netmask_admin_eth0': '255.255.255.0'}
assert await conf1.value.dict() == {'ip_admin_eth0': '192.168.1.1', 'netmask_admin_eth0': '255.255.255.0'}
assert await conf2.value.dict() == {'ip_admin_eth0': '192.168.1.1', 'netmask_admin_eth0': None}
copy_meta2 = await conf1.config.deepcopy(session_id='copy_conf1', metaconfig_prefix='copy_')
assert await copy_meta2.config.path() == 'copy_meta2'
copy_meta1 = await copy_meta2.config('copy_meta1')
copy_conf1 = await copy_meta1.config('copy_conf1')
assert await copy_meta2.value.dict() == {'ip_admin_eth0': None, 'netmask_admin_eth0': '255.255.255.0'}
assert await copy_conf1.value.dict() == {'ip_admin_eth0': '192.168.1.1', 'netmask_admin_eth0': '255.255.255.0'}
await delete_sessions([conf1, conf2, meta1, meta2, copy_conf1, copy_meta1, copy_meta2])
@pytest.mark.asyncio
async def test_meta_properties_submeta_deepcopy():
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])