2019-08-01 18:22:18 +02:00
|
|
|
# from json import dumps, loads
|
2020-01-22 20:46:18 +01:00
|
|
|
import asyncio
|
|
|
|
from os import environ
|
2019-08-01 18:22:18 +02:00
|
|
|
try:
|
2019-08-03 21:03:23 +02:00
|
|
|
from tiramisu_api import Config
|
2019-08-01 18:22:18 +02:00
|
|
|
class TestConfig(Config):
|
|
|
|
def __init__(self,
|
|
|
|
config):
|
|
|
|
self.test_option = config.option
|
|
|
|
json = self.test_option.dict()
|
|
|
|
# assert json == loads(dumps(json))
|
|
|
|
super().__init__(json)
|
|
|
|
|
|
|
|
def send_data(self,
|
|
|
|
updates):
|
|
|
|
return self.updates_data(self.test_option.updates(updates))
|
|
|
|
PARAMS = ['tiramisu', 'tiramisu-api']
|
|
|
|
except:
|
|
|
|
PARAMS = ['tiramisu']
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2023-04-15 16:12:35 +02:00
|
|
|
def get_config(config, type, error=False):
|
2019-08-01 18:22:18 +02:00
|
|
|
if type == 'tiramisu':
|
|
|
|
return config
|
|
|
|
if error:
|
2023-04-15 16:12:35 +02:00
|
|
|
config.property.add('demoting_error_warning')
|
2019-08-01 18:22:18 +02:00
|
|
|
return TestConfig(config)
|
|
|
|
|
|
|
|
|
|
|
|
def value_list(values):
|
|
|
|
if values[0] == '':
|
|
|
|
del values[0]
|
|
|
|
return tuple(values)
|
|
|
|
|
|
|
|
|
2023-04-15 16:12:35 +02:00
|
|
|
def global_owner(config, config_type):
|
|
|
|
return config.owner.get()
|
2019-08-01 18:22:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=PARAMS)
|
|
|
|
def config_type(request):
|
|
|
|
return request.param
|
2024-04-24 15:39:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
def parse_od_get(dico):
|
|
|
|
ret = {}
|
|
|
|
for k, v in dico.items():
|
|
|
|
if k.isoptiondescription():
|
|
|
|
if k.isleadership():
|
|
|
|
leader_path = k.leader().path()
|
|
|
|
ret_leadership = []
|
|
|
|
for variable, value in v.items():
|
|
|
|
if variable.path() == leader_path:
|
|
|
|
for val in value:
|
|
|
|
ret_leadership.append({leader_path: val})
|
|
|
|
else:
|
|
|
|
ret_leadership[variable.index()][variable.path()] = value
|
|
|
|
ret[leader_path] = ret_leadership
|
|
|
|
else:
|
|
|
|
ret.update(parse_od_get(v))
|
|
|
|
else:
|
|
|
|
ret[k.path()] = v
|
|
|
|
return ret
|