update tests

This commit is contained in:
Emmanuel Garette 2019-12-26 15:33:51 +01:00
parent 1d25d3a582
commit 50aa8019ab
18 changed files with 464 additions and 352 deletions

View File

@ -5,6 +5,10 @@ from .context import Context
class Controller: class Controller:
"""Common controller used to add a service in Risotto """Common controller used to add a service in Risotto
""" """
def __init__(self,
test: bool):
pass
async def call(self, async def call(self,
uri: str, uri: str,
risotto_context: Context, risotto_context: Context,

View File

@ -218,11 +218,11 @@ class RegisterDispatcher:
dico['notification'] = notification dico['notification'] = notification
self.messages[version][message]['functions'].append(dico) self.messages[version][message]['functions'].append(dico)
def set_module(self, module_name, module): def set_module(self, module_name, module, test):
""" register and instanciate a new module """ register and instanciate a new module
""" """
try: try:
self.injected_self[module_name] = module.Risotto() self.injected_self[module_name] = module.Risotto(test)
except AttributeError as err: except AttributeError as err:
raise RegistrationError(_(f'unable to register the module {module_name}, this module must have Risotto class')) raise RegistrationError(_(f'unable to register the module {module_name}, this module must have Risotto class'))

View File

@ -5,7 +5,8 @@ from ..dispatcher import dispatcher
def load_services(modules=None, def load_services(modules=None,
validate: bool=True): validate: bool=True,
test: bool=False):
abs_here = dirname(abspath(__file__)) abs_here = dirname(abspath(__file__))
here = basename(abs_here) here = basename(abs_here)
module = basename(dirname(abs_here)) module = basename(dirname(abs_here))
@ -14,6 +15,6 @@ def load_services(modules=None,
for filename in modules: for filename in modules:
absfilename = join(abs_here, filename) absfilename = join(abs_here, filename)
if isdir(absfilename) and isfile(join(absfilename, '__init__.py')): if isdir(absfilename) and isfile(join(absfilename, '__init__.py')):
dispatcher.set_module(filename, import_module(f'.{here}.{filename}', module)) dispatcher.set_module(filename, import_module(f'.{here}.{filename}', module), test)
if validate: if validate:
dispatcher.validate() dispatcher.validate()

View File

@ -19,15 +19,18 @@ from ...logger import log
class Risotto(Controller): class Risotto(Controller):
def __init__(self) -> None: def __init__(self,
test) -> None:
global conf_storage
self.cache_root_path = join(get_config().get('cache').get('root_path'), 'servermodel') self.cache_root_path = join(get_config().get('cache').get('root_path'), 'servermodel')
for dirname in [self.cache_root_path, DATABASE_DIR]: for dirname in [self.cache_root_path, DATABASE_DIR]:
if not isdir(dirname): if not isdir(dirname):
raise RegistrationError(_(f'unable to find the cache dir "{dirname}"')) raise RegistrationError(_(f'unable to find the cache dir "{dirname}"'))
if not test:
self.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR) self.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR)
self.servermodel = {} self.servermodel = {}
self.server = {} self.server = {}
super().__init__() super().__init__(test)
async def on_join(self, async def on_join(self,
risotto_context: Context) -> None: risotto_context: Context) -> None:
@ -80,28 +83,7 @@ class Risotto(Controller):
None, None,
f'Load servermodel {servermodel_name} ({servermodel_id})') f'Load servermodel {servermodel_name} ({servermodel_id})')
# use file in cache if found, otherwise retrieve it in servermodel context # use file in cache
# if isfile(cache_file):
# fileio = open(cache_file)
# else:
# servermodel = await self.call('v1.servermodel.describe',
# risotto_context,
# servermodel_id=servermodel_id,
# inheritance=False,
# resolvdepends=False,
# schema=True,
# creolefuncs=True)
# fileio = BytesIO()
# fileio.write(servermodel['schema'].encode())
# fileio.seek(0)
#
# with open(cache_file, 'w') as cache:
# cache.write(servermodel['schema'])
# with open(funcs_file, 'w') as cache:
# cache.write(servermodel['creolefuncs'])
# del servermodel
#
# # loads tiramisu config and store it
with open(cache_file) as fileio: with open(cache_file) as fileio:
xmlroot = parse(fileio).getroot() xmlroot = parse(fileio).getroot()
self.servermodel[servermodel_id] = await self.build_metaconfig(servermodel_id, self.servermodel[servermodel_id] = await self.build_metaconfig(servermodel_id,
@ -289,7 +271,7 @@ class Risotto(Controller):
for server_type in ['server', 'server_to_deploy']: for server_type in ['server', 'server_to_deploy']:
config = self.server[server_id]['server'] config = self.server[server_id]['server']
for parent in await config.config.parents(): for parent in await config.config.parents():
await parent.config.pop(config.config.name()) await parent.config.pop(await config.config.name())
delete_session(storage=self.save_storage, delete_session(storage=self.save_storage,
session_id=await config.config.name()) session_id=await config.config.name())
# delete metaconfig # delete metaconfig
@ -341,46 +323,46 @@ class Risotto(Controller):
delete_session(storage=self.save_storage, delete_session(storage=self.save_storage,
session_id=await metaconfig.config.name()) session_id=await metaconfig.config.name())
return children return children
#
@register('v1.servermodel.updated') # @register('v1.servermodel.updated')
async def servermodel_updated(self, # async def servermodel_updated(self,
risotto_context: Context, # risotto_context: Context,
servermodel_id: int, # servermodel_id: int,
servermodel_name: str, # servermodel_name: str,
servermodel_parents_id: List[int]) -> None: # servermodel_parents_id: List[int]) -> None:
log.info_msg(risotto_context, # log.info_msg(risotto_context,
None, # None,
f'Reload servermodel {servermodel_name} ({servermodel_id})') # f'Reload servermodel {servermodel_name} ({servermodel_id})')
# unlink cache to force download new aggregated file # # unlink cache to force download new aggregated file
cache_file = join(self.cache_root_path, str(servermodel_id)+".xml") # cache_file = join(self.cache_root_path, str(servermodel_id)+".xml")
if isfile(cache_file): # if isfile(cache_file):
unlink(cache_file) # unlink(cache_file)
#
# store all informations # # store all informations
if servermodel_id in self.servermodel: # if servermodel_id in self.servermodel:
old_values = await self.servermodel[servermodel_id].value.exportation() # old_values = await self.servermodel[servermodel_id].value.exportation()
old_permissives = await self.servermodel[servermodel_id].permissive.exportation() # old_permissives = await self.servermodel[servermodel_id].permissive.exportation()
old_properties = await self.servermodel[servermodel_id].property.exportation() # old_properties = await self.servermodel[servermodel_id].property.exportation()
children = await self.servermodel_delete(servermodel_id) # children = await self.servermodel_delete(servermodel_id)
else: # else:
old_values = None # old_values = None
#
# create new one # # create new one
await self.load_and_link_servermodel(risotto_context, # await self.load_and_link_servermodel(risotto_context,
servermodel_id, # servermodel_id,
servermodel_name, # servermodel_name,
servermodel_parents_id) # servermodel_parents_id)
#
# migrates informations # # migrates informations
if old_values is not None: # if old_values is not None:
await self.servermodel[servermodel_id].value.importation(old_values) # await self.servermodel[servermodel_id].value.importation(old_values)
await self.servermodel[servermodel_id].permissive.importation(old_permissives) # await self.servermodel[servermodel_id].permissive.importation(old_permissives)
await self.servermodel[servermodel_id].property.importation(old_properties) # await self.servermodel[servermodel_id].property.importation(old_properties)
for child in children: # for child in children:
await self.servermodel_legacy(risotto_context, # await self.servermodel_legacy(risotto_context,
await child.information.get('servermodel_name'), # await child.information.get('servermodel_name'),
await child.information.get('servermodel_id'), # await child.information.get('servermodel_id'),
servermodel_id) # servermodel_id)
@register('v1.config.configuration.server.get', None) @register('v1.config.configuration.server.get', None)
async def get_configuration(self, async def get_configuration(self,

View File

@ -41,7 +41,7 @@ class Risotto(Controller):
'server_servermodel_id': server_servermodel_id} 'server_servermodel_id': server_servermodel_id}
@register('v1.server.describe', None, database=True) @register('v1.server.describe', None, database=True)
async def server_create(self, async def server_describe(self,
risotto_context: Context, risotto_context: Context,
server_name: str) -> Dict: server_name: str) -> Dict:
sql = ''' sql = '''

View File

@ -16,7 +16,8 @@ from ...dispatcher import dispatcher
class Risotto(Controller): class Risotto(Controller):
def __init__(self): def __init__(self,
test):
self.modify_storage = Storage(engine='dictionary') self.modify_storage = Storage(engine='dictionary')
def get_storage(self, def get_storage(self,
@ -221,7 +222,7 @@ class Risotto(Controller):
type) type)
info = self.format_session(session_id, session) info = self.format_session(session_id, session)
if name is not None: if name is not None:
content = {name: await session['option'].option(name).value.get()} content = {name: await session['config'].option(name).value.get()}
else: else:
content = await session['option'].value.dict(fullpath=True, content = await session['option'].value.dict(fullpath=True,
leader_to_list=True) leader_to_list=True)

View File

@ -44,7 +44,7 @@ class Storage(object):
break break
await config.property.read_write() await config.property.read_write()
# set the default owner # set the default owner
self.set_owner(config, await self.set_owner(config,
username) username)
# store it # store it
@ -113,10 +113,10 @@ class StorageServer(Storage):
server_id: int): server_id: int):
return f'std_{server_id}' return f'std_{server_id}'
def set_owner(self, async def set_owner(self,
config: Config, config: Config,
username: str): username: str):
config.owner.set(username) await config.owner.set(username)
class StorageServermodel(Storage): class StorageServermodel(Storage):
@ -124,10 +124,10 @@ class StorageServermodel(Storage):
server_id: int): server_id: int):
return f'v_{server_id}' return f'v_{server_id}'
def set_owner(self, async def set_owner(self,
config: Config, config: Config,
username: str): username: str):
config.owner.set('servermodel_' + username) await config.owner.set('servermodel_' + username)
storage_server = StorageServer() storage_server = StorageServer()

View File

@ -0,0 +1,50 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="containers">
<family name="container0" doc="test">
<family doc="files" name="files">
<family doc="file0" name="file0">
<variable doc="" multi="False" name="mkdir" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="name" type="string">
<value>/etc/mailname</value>
</variable>
<variable doc="" multi="False" name="rm" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
<leader doc="master" name="master">
<property>normal</property>
<variable doc="master" multi="True" name="master" type="string"/>
<variable doc="slave1" multi="True" name="slave1" type="string">
<property>normal</property>
</variable>
<variable doc="slave2" multi="True" name="slave2" type="string">
<property>normal</property>
</variable>
</leader>
</family>
<separators/>
</family>
</creole>

0
tests/data/1/funcs.py Normal file
View File

View File

@ -0,0 +1,50 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="containers">
<family name="container0" doc="test">
<family doc="files" name="files">
<family doc="file0" name="file0">
<variable doc="" multi="False" name="mkdir" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="name" type="string">
<value>/etc/mailname</value>
</variable>
<variable doc="" multi="False" name="rm" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
<leader doc="master" name="master">
<property>normal</property>
<variable doc="master" multi="True" name="master" type="string"/>
<variable doc="slave1" multi="True" name="slave1" type="string">
<property>normal</property>
</variable>
<variable doc="slave2" multi="True" name="slave2" type="string">
<property>normal</property>
</variable>
</leader>
</family>
<separators/>
</family>
</creole>

0
tests/data/2/funcs.py Normal file
View File

View File

@ -0,0 +1,50 @@
<?xml version='1.0' encoding='UTF-8'?>
<creole>
<family name="containers">
<family name="container0" doc="test">
<family doc="files" name="files">
<family doc="file0" name="file0">
<variable doc="" multi="False" name="mkdir" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="name" type="string">
<value>/etc/mailname</value>
</variable>
<variable doc="" multi="False" name="rm" type="boolean">
<value>False</value>
</variable>
<variable doc="" multi="False" name="source" type="string">
<value>mailname</value>
</variable>
<variable doc="" multi="False" name="activate" type="boolean">
<value>True</value>
</variable>
</family>
</family>
<property>basic</property>
</family>
</family>
<family doc="" name="creole">
<family doc="general" name="general">
<property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
<choice type="string">oui</choice>
<choice type="string">non</choice>
<property>mandatory</property>
<property>normal</property>
<value type="string">non</value>
</variable>
<leader doc="master" name="master">
<property>normal</property>
<variable doc="master" multi="True" name="master" type="string"/>
<variable doc="slave1" multi="True" name="slave1" type="string">
<property>normal</property>
</variable>
<variable doc="slave2" multi="True" name="slave2" type="string">
<property>normal</property>
</variable>
</leader>
</family>
<separators/>
</family>
</creole>

0
tests/data/3/funcs.py Normal file
View File

View File

@ -5,4 +5,4 @@ from risotto.register import register
class Risotto(Controller): class Risotto(Controller):
@register('v1.server.list', None) @register('v1.server.list', None)
async def server_list(self): async def server_list(self):
return [{'server_id': 3, 'servername': 'one', 'serverdescription': 'the first', 'servermodelid': 1}] return [{'server_id': 3, 'server_name': 'one', 'server_description': 'the first', 'server_servermodel_id': 1}]

View File

@ -13,63 +13,3 @@ class Risotto(Controller):
'release_id': 2, 'release_id': 2,
'servermodel_description': 'description2', 'servermodel_description': 'description2',
'servermodel_parents_id': [1]}] 'servermodel_parents_id': [1]}]
# @register('v1.servermodel.describe', None)
# async def servermodel_describe(self,
# servermodel_id,
# inheritance,
# resolv_depends):
# schema = """<?xml version='1.0' encoding='UTF-8'?>
#<creole>
# <family name="containers">
# <family name="container0" doc="test">
# <family doc="files" name="files">
# <family doc="file0" name="file0">
# <variable doc="" multi="False" name="mkdir" type="boolean">
# <value>False</value>
# </variable>
# <variable doc="" multi="False" name="name" type="string">
# <value>/etc/mailname</value>
# </variable>
# <variable doc="" multi="False" name="rm" type="boolean">
# <value>False</value>
# </variable>
# <variable doc="" multi="False" name="source" type="string">
# <value>mailname</value>
# </variable>
# <variable doc="" multi="False" name="activate" type="boolean">
# <value>True</value>
# </variable>
# </family>
# </family>
# <property>basic</property>
# </family>
# </family>
# <family doc="" name="creole">
# <family doc="general" name="general">
# <property>normal</property>
# <variable doc="No change" multi="False" name="mode_conteneur_actif" type="choice">
# <choice type="string">oui</choice>
# <choice type="string">non</choice>
# <property>mandatory</property>
# <property>normal</property>
# <value type="string">non</value>
# </variable>
# <leader doc="master" name="master">
# <property>normal</property>
# <variable doc="master" multi="True" name="master" type="string"/>
# <variable doc="slave1" multi="True" name="slave1" type="string">
# <property>normal</property>
# </variable>
# <variable doc="slave2" multi="True" name="slave2" type="string">
# <property>normal</property>
# </variable>
# </leader>
# </family>
# <separators/>
# </family>
#</creole>"""
# return {'servermodel_id': 1,
# 'servermodel_name': 'name',
# 'servermodel_description': 'description',
# 'release_id': 1}

5
tests/storage.py Normal file
View File

@ -0,0 +1,5 @@
from tiramisu import Storage
from risotto.config import DATABASE_DIR
STORAGE = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test')

View File

@ -1,20 +1,20 @@
from importlib import import_module from importlib import import_module
import pytest import pytest
from tiramisu import Storage, list_sessions, delete_session from tiramisu import list_sessions, delete_session
from .storage import STORAGE
from risotto.context import Context from risotto.context import Context
from risotto.services import load_services from risotto.services import load_services
from risotto.dispatcher import dispatcher from risotto.dispatcher import dispatcher
from risotto.config import DATABASE_DIR
def setup_module(module): def setup_module(module):
load_services(['config'], load_services(['config'],
validate=False) validate=False)
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test') config_module.save_storage = STORAGE
dispatcher.set_module('server', import_module(f'.server', 'fake_services')) dispatcher.set_module('server', import_module(f'.server', 'fake_services'), True)
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services')) dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'), True)
def setup_function(function): def setup_function(function):
@ -45,17 +45,19 @@ async def test_on_join():
assert config_module.server == {} assert config_module.server == {}
# #
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
assert list(config_module.servermodel.keys()) == [1, 2] assert list(config_module.servermodel.keys()) == [1, 2]
assert list(config_module.server) == [3] assert list(config_module.server) == [3]
assert set(config_module.server[3]) == {'server', 'server_to_deploy', 'funcs_file'} assert set(config_module.server[3]) == {'server', 'server_to_deploy', 'funcs_file'}
assert config_module.server[3]['funcs_file'] == 'cache/1.creolefuncs' assert config_module.server[3]['funcs_file'] == 'tests/data/1/funcs.py'
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_server_created(): async def test_server_created():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
assert list(config_module.server) == [3] assert list(config_module.server) == [3]
@ -63,18 +65,19 @@ async def test_server_created():
'server.created', 'server.created',
fake_context, fake_context,
server_id=4, server_id=4,
servername='name3', server_name='name3',
serverdescription='description3', server_description='description3',
servermodelid=2) server_servermodel_id=2)
assert list(config_module.server) == [3, 4] assert list(config_module.server) == [3, 4]
assert set(config_module.server[4]) == {'server', 'server_to_deploy', 'funcs_file'} assert set(config_module.server[4]) == {'server', 'server_to_deploy', 'funcs_file'}
assert config_module.server[4]['funcs_file'] == 'cache/2.creolefuncs' assert config_module.server[4]['funcs_file'] == 'tests/data/2/funcs.py'
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_server_deleted(): async def test_server_deleted():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
assert list(config_module.server) == [3] assert list(config_module.server) == [3]
@ -82,9 +85,9 @@ async def test_server_deleted():
'server.created', 'server.created',
fake_context, fake_context,
server_id=4, server_id=4,
servername='name4', server_name='name4',
serverdescription='description4', server_description='description4',
servermodelid=2) server_servermodel_id=2)
assert list(config_module.server) == [3, 4] assert list(config_module.server) == [3, 4]
await dispatcher.publish('v1', await dispatcher.publish('v1',
'server.deleted', 'server.deleted',
@ -97,6 +100,7 @@ async def test_server_deleted():
async def test_servermodel_created(): async def test_servermodel_created():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
assert list(config_module.servermodel) == [1, 2] assert list(config_module.servermodel) == [1, 2]
@ -110,13 +114,14 @@ async def test_servermodel_created():
release_id=1, release_id=1,
servermodel_name='name3') servermodel_name='name3')
assert list(config_module.servermodel) == [1, 2, 3] assert list(config_module.servermodel) == [1, 2, 3]
assert not list(config_module.servermodel[3].config.parents()) assert not list(await config_module.servermodel[3].config.parents())
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_servermodel_herited_created(): async def test_servermodel_herited_created():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
assert list(config_module.servermodel) == [1, 2] assert list(config_module.servermodel) == [1, 2]
@ -129,13 +134,14 @@ async def test_servermodel_herited_created():
servermodel_description='name3', servermodel_description='name3',
servermodel_parents_id=[1]) servermodel_parents_id=[1])
assert list(config_module.servermodel) == [1, 2, 3] assert list(config_module.servermodel) == [1, 2, 3]
assert len(list(config_module.servermodel[3].config.parents())) == 1 assert len(list(await config_module.servermodel[3].config.parents())) == 1
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_servermodel_multi_herited_created(): async def test_servermodel_multi_herited_created():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
assert list(config_module.servermodel) == [1, 2] assert list(config_module.servermodel) == [1, 2]
@ -148,136 +154,141 @@ async def test_servermodel_multi_herited_created():
servermodel_description='name3', servermodel_description='name3',
servermodel_parents_id=[1, 2]) servermodel_parents_id=[1, 2])
assert list(config_module.servermodel) == [1, 2, 3] assert list(config_module.servermodel) == [1, 2, 3]
assert len(list(config_module.servermodel[3].config.parents())) == 2 assert len(list(await config_module.servermodel[3].config.parents())) == 2
@pytest.mark.asyncio #@pytest.mark.asyncio
async def test_servermodel_updated_not_exists(): #async def test_servermodel_updated_not_exists():
config_module = dispatcher.get_service('config') # config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') # fake_context = get_fake_context('config')
await config_module.on_join(fake_context) # config_module.cache_root_path = 'tests/data'
# # await config_module.on_join(fake_context)
assert list(config_module.servermodel) == [1, 2] # #
await dispatcher.publish('v1', # assert list(config_module.servermodel) == [1, 2]
'servermodel.updated', # await dispatcher.publish('v1',
fake_context, # 'servermodel.updated',
servermodel_id=3, # fake_context,
servermodel_name='name3', # servermodel_id=3,
release_id=1, # servermodel_name='name3',
servermodel_description='name3', # release_id=1,
servermodel_parents_id=[1, 2]) # servermodel_description='name3',
assert list(config_module.servermodel) == [1, 2, 3] # servermodel_parents_id=[1, 2])
assert len(list(config_module.servermodel[3].config.parents())) == 2 # assert list(config_module.servermodel) == [1, 2, 3]
# assert len(list(await config_module.servermodel[3].config.parents())) == 2
#
@pytest.mark.asyncio #
async def test_servermodel_updated1(): # @pytest.mark.asyncio
config_module = dispatcher.get_service('config') # async def test_servermodel_updated1():
fake_context = get_fake_context('config') # config_module = dispatcher.get_service('config')
await config_module.on_join(fake_context) # fake_context = get_fake_context('config')
# # config_module.cache_root_path = 'tests/data'
assert list(config_module.servermodel) == [1, 2] # await config_module.on_join(fake_context)
metaconfig1 = config_module.servermodel[1] # #
metaconfig2 = config_module.servermodel[2] # assert list(config_module.servermodel) == [1, 2]
mixconfig1 = next(metaconfig1.config.list()) # metaconfig1 = config_module.servermodel[1]
mixconfig2 = next(metaconfig2.config.list()) # metaconfig2 = config_module.servermodel[2]
assert len(list(metaconfig1.config.parents())) == 0 # mixconfig1 = (await metaconfig1.config.list())[0]
assert len(list(metaconfig2.config.parents())) == 1 # mixconfig2 = (await metaconfig2.config.list())[0]
assert len(list(mixconfig1.config.list())) == 1 # assert len(list(await metaconfig1.config.parents())) == 0
assert len(list(mixconfig2.config.list())) == 0 # assert len(list(await metaconfig2.config.parents())) == 1
# # assert len(list(await mixconfig1.config.list())) == 1
await dispatcher.publish('v1', # assert len(list(await mixconfig2.config.list())) == 0
'servermodel.updated', # #
fake_context, # await dispatcher.publish('v1',
servermodel_id=1, # 'servermodel.updated',
servermodel_name='name1-1', # fake_context,
release_id=1, # servermodel_id=1,
servermodel_description='name1-1') # servermodel_name='name1-1',
assert set(config_module.servermodel) == {1, 2} # release_id=1,
assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1' # servermodel_description='name1-1')
assert metaconfig1 != config_module.servermodel[1] # assert set(config_module.servermodel) == {1, 2}
assert metaconfig2 == config_module.servermodel[2] # assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1'
metaconfig1 = config_module.servermodel[1] # assert metaconfig1 != config_module.servermodel[1]
assert mixconfig1 != next(metaconfig1.config.list()) # assert metaconfig2 == config_module.servermodel[2]
mixconfig1 = next(metaconfig1.config.list()) # metaconfig1 = config_module.servermodel[1]
# # assert mixconfig1 != next(metaconfig1.config.list())
assert len(list(metaconfig1.config.parents())) == 0 # mixconfig1 = next(metaconfig1.config.list())
assert len(list(metaconfig2.config.parents())) == 1 # #
assert len(list(mixconfig1.config.list())) == 1 # assert len(list(await metaconfig1.config.parents())) == 0
assert len(list(mixconfig2.config.list())) == 0 # assert len(list(await metaconfig2.config.parents())) == 1
# assert len(list(await mixconfig1.config.list())) == 1
# assert len(list(await mixconfig2.config.list())) == 0
@pytest.mark.asyncio #
async def test_servermodel_updated2(): #
config_module = dispatcher.get_service('config') # @pytest.mark.asyncio
fake_context = get_fake_context('config') # async def test_servermodel_updated2():
await config_module.on_join(fake_context) # config_module = dispatcher.get_service('config')
# create a new servermodel # fake_context = get_fake_context('config')
assert list(config_module.servermodel) == [1, 2] # config_module.cache_root_path = 'tests/data'
mixconfig1 = next(config_module.servermodel[1].config.list()) # await config_module.on_join(fake_context)
mixconfig2 = next(config_module.servermodel[2].config.list()) # # create a new servermodel
assert len(list(mixconfig1.config.list())) == 1 # assert list(config_module.servermodel) == [1, 2]
assert len(list(mixconfig2.config.list())) == 0 # mixconfig1 = next(config_module.servermodel[1].config.list())
await dispatcher.publish('v1', # mixconfig2 = next(config_module.servermodel[2].config.list())
'servermodel.created', # assert len(list(mixconfig1.config.list())) == 1
fake_context, # assert len(list(mixconfig2.config.list())) == 0
servermodel_id=3, # await dispatcher.publish('v1',
servermodel_name='name3', # 'servermodel.created',
release_id=1, # fake_context,
servermodel_description='name3', # servermodel_id=3,
servermodel_parents_id=[1]) # servermodel_name='name3',
assert list(config_module.servermodel) == [1, 2, 3] # release_id=1,
assert len(list(config_module.servermodel[3].config.parents())) == 1 # servermodel_description='name3',
assert config_module.servermodel[3].information.get('servermodel_name') == 'name3' # servermodel_parents_id=[1])
assert len(list(mixconfig1.config.list())) == 2 # assert list(config_module.servermodel) == [1, 2, 3]
assert len(list(mixconfig2.config.list())) == 0 # assert len(list(await config_module.servermodel[3].config.parents())) == 1
# # assert await config_module.servermodel[3].information.get('servermodel_name') == 'name3'
await dispatcher.publish('v1', # assert len(list(await mixconfig1.config.list())) == 2
'servermodel.updated', # assert len(list(await mixconfig2.config.list())) == 0
fake_context, # #
servermodel_id=3, # await dispatcher.publish('v1',
servermodel_name='name3-1', # 'servermodel.updated',
release_id=1, # fake_context,
servermodel_description='name3-1', # servermodel_id=3,
servermodel_parents_id=[1, 2]) # servermodel_name='name3-1',
assert list(config_module.servermodel) == [1, 2, 3] # release_id=1,
assert config_module.servermodel[3].information.get('servermodel_name') == 'name3-1' # servermodel_description='name3-1',
assert len(list(mixconfig1.config.list())) == 2 # servermodel_parents_id=[1, 2])
assert len(list(mixconfig2.config.list())) == 1 # assert list(config_module.servermodel) == [1, 2, 3]
# assert config_module.servermodel[3].information.get('servermodel_name') == 'name3-1'
# assert len(list(mixconfig1.config.list())) == 2
@pytest.mark.asyncio # assert len(list(mixconfig2.config.list())) == 1
async def test_servermodel_updated_config(): #
config_module = dispatcher.get_service('config') #
fake_context = get_fake_context('config') # @pytest.mark.asyncio
await config_module.on_join(fake_context) # async def test_servermodel_updated_config():
# # config_module = dispatcher.get_service('config')
config_module.servermodel[1].property.read_write() # fake_context = get_fake_context('config')
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'non' # config_module.cache_root_path = 'tests/data'
config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.set('oui') # await config_module.on_join(fake_context)
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui' # #
# # config_module.servermodel[1].property.read_write()
await dispatcher.publish('v1', # assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'non'
'servermodel.updated', # config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.set('oui')
fake_context, # assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
servermodel_id=1, # #
servermodel_name='name1-1', # await dispatcher.publish('v1',
release_id=1, # 'servermodel.updated',
servermodel_description='name1-1') # fake_context,
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui' # servermodel_id=1,
# servermodel_name='name1-1',
# release_id=1,
# servermodel_description='name1-1')
# assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_server_configuration_get(): async def test_server_configuration_get():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
config_module.server[3]['server_to_deploy'].property.read_write() await config_module.server[3]['server_to_deploy'].property.read_write()
assert config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non' assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui') await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui')
assert config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui' assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
assert config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non' assert await config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
# #
values = await dispatcher.call('v1', values = await dispatcher.call('v1',
'config.configuration.server.get', 'config.configuration.server.get',
@ -311,16 +322,17 @@ async def test_server_configuration_get():
async def test_config_deployed(): async def test_config_deployed():
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
fake_context = get_fake_context('config') fake_context = get_fake_context('config')
config_module.cache_root_path = 'tests/data'
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
# #
config_module.server[3]['server_to_deploy'].property.read_write() await config_module.server[3]['server_to_deploy'].property.read_write()
assert config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non' assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui') await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui')
assert config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui' assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
assert config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non' assert await config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
values = await dispatcher.publish('v1', values = await dispatcher.publish('v1',
'config.configuration.server.deploy', 'config.configuration.server.deploy',
fake_context, fake_context,
server_id=3) server_id=3)
assert config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui' assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
assert config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'oui' assert await config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'

View File

@ -1,10 +1,9 @@
from importlib import import_module from importlib import import_module
import pytest import pytest
from tiramisu import Storage from .storage import STORAGE
from risotto.context import Context from risotto.context import Context
from risotto.services import load_services from risotto.services import load_services
from risotto.dispatcher import dispatcher from risotto.dispatcher import dispatcher
from risotto.config import DATABASE_DIR
from risotto.services.session.storage import storage_server, storage_servermodel from risotto.services.session.storage import storage_server, storage_servermodel
@ -18,11 +17,13 @@ def get_fake_context(module_name):
def setup_module(module): def setup_module(module):
load_services(['config', 'session'], load_services(['config', 'session'],
validate=False) validate=False,
test=True)
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test') config_module.save_storage = STORAGE
dispatcher.set_module('server', import_module(f'.server', 'fake_services')) dispatcher.set_module('server', import_module(f'.server', 'fake_services'), True)
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services')) dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'), True)
dispatcher.injected_self['servermodel'].cache_root_path = 'tests/data'
def teardown_function(function): def teardown_function(function):
@ -35,6 +36,7 @@ def teardown_function(function):
async def test_server_start(): async def test_server_start():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
await dispatcher.call('v1', await dispatcher.call('v1',
@ -47,6 +49,7 @@ async def test_server_start():
async def test_server_list(): async def test_server_list():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
assert not await dispatcher.call('v1', assert not await dispatcher.call('v1',
@ -65,6 +68,7 @@ async def test_server_list():
async def test_server_filter_namespace(): async def test_server_filter_namespace():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -88,6 +92,7 @@ async def test_server_filter_namespace():
async def test_server_filter_mode(): async def test_server_filter_mode():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -112,6 +117,7 @@ async def test_server_filter_mode():
async def test_server_filter_debug(): async def test_server_filter_debug():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -137,6 +143,7 @@ async def test_server_filter_debug():
async def test_server_filter_get(): async def test_server_filter_get():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -148,10 +155,8 @@ async def test_server_filter_get():
'session.server.get', 'session.server.get',
fake_context, fake_context,
session_id=session_id) session_id=session_id)
assert values == {'content': {"general.mode_conteneur_actif": "non", assert values == {'content': {"creole.general.mode_conteneur_actif": "non",
"general.master.master": [], "creole.general.master.master": []},
"general.master.slave1": [],
"general.master.slave2": []},
'debug': False, 'debug': False,
'id': 3, 'id': 3,
'mode': 'normal', 'mode': 'normal',
@ -165,6 +170,7 @@ async def test_server_filter_get():
async def test_server_filter_get_one_value(): async def test_server_filter_get_one_value():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -176,8 +182,8 @@ async def test_server_filter_get_one_value():
'session.server.get', 'session.server.get',
fake_context, fake_context,
session_id=session_id, session_id=session_id,
name="general.mode_conteneur_actif") name="creole.general.mode_conteneur_actif")
assert values == {'content': {"general.mode_conteneur_actif": "non"}, assert values == {'content': {"creole.general.mode_conteneur_actif": "non"},
'debug': False, 'debug': False,
'id': 3, 'id': 3,
'mode': 'normal', 'mode': 'normal',
@ -191,6 +197,7 @@ async def test_server_filter_get_one_value():
async def test_server_filter_configure(): async def test_server_filter_configure():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -203,7 +210,7 @@ async def test_server_filter_configure():
fake_context, fake_context,
session_id=session_id, session_id=session_id,
action='modify', action='modify',
name='general.mode_conteneur_actif', name='creole.general.mode_conteneur_actif',
value='oui') value='oui')
list_result = await dispatcher.call('v1', list_result = await dispatcher.call('v1',
'session.server.list', 'session.server.list',
@ -212,8 +219,8 @@ async def test_server_filter_configure():
'session.server.get', 'session.server.get',
fake_context, fake_context,
session_id=session_id, session_id=session_id,
name="general.mode_conteneur_actif") name="creole.general.mode_conteneur_actif")
assert values == {'content': {"general.mode_conteneur_actif": "oui"}, assert values == {'content': {"creole.general.mode_conteneur_actif": "oui"},
'debug': False, 'debug': False,
'id': 3, 'id': 3,
'mode': 'normal', 'mode': 'normal',
@ -227,6 +234,7 @@ async def test_server_filter_configure():
async def test_server_filter_validate(): async def test_server_filter_validate():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -244,6 +252,7 @@ async def test_server_filter_validate():
async def test_server_stop(): async def test_server_stop():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.server: if not config_module.server:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
assert not await dispatcher.call('v1', assert not await dispatcher.call('v1',
@ -271,6 +280,7 @@ async def test_server_stop():
async def test_servermodel_start(): async def test_servermodel_start():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
await dispatcher.call('v1', await dispatcher.call('v1',
@ -283,6 +293,7 @@ async def test_servermodel_start():
async def test_servermodel_list(): async def test_servermodel_list():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
assert not await dispatcher.call('v1', assert not await dispatcher.call('v1',
@ -301,6 +312,7 @@ async def test_servermodel_list():
async def test_servermodel_filter_namespace(): async def test_servermodel_filter_namespace():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -324,6 +336,7 @@ async def test_servermodel_filter_namespace():
async def test_servermodel_filter_mode(): async def test_servermodel_filter_mode():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -348,6 +361,7 @@ async def test_servermodel_filter_mode():
async def test_servermodel_filter_debug(): async def test_servermodel_filter_debug():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -372,6 +386,7 @@ async def test_servermodel_filter_debug():
async def test_servermodel_filter_get(): async def test_servermodel_filter_get():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -383,10 +398,8 @@ async def test_servermodel_filter_get():
'session.servermodel.get', 'session.servermodel.get',
fake_context, fake_context,
session_id=session_id) session_id=session_id)
assert values == {'content': {"general.mode_conteneur_actif": "non", assert values == {'content': {"creole.general.mode_conteneur_actif": "non",
"general.master.master": [], "creole.general.master.master": []},
"general.master.slave1": [],
"general.master.slave2": []},
'debug': False, 'debug': False,
'id': 1, 'id': 1,
'mode': 'normal', 'mode': 'normal',
@ -400,6 +413,7 @@ async def test_servermodel_filter_get():
async def test_servermodel_filter_get_one_value(): async def test_servermodel_filter_get_one_value():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -411,8 +425,8 @@ async def test_servermodel_filter_get_one_value():
'session.servermodel.get', 'session.servermodel.get',
fake_context, fake_context,
session_id=session_id, session_id=session_id,
name="general.mode_conteneur_actif") name="creole.general.mode_conteneur_actif")
assert values == {'content': {"general.mode_conteneur_actif": "non"}, assert values == {'content': {"creole.general.mode_conteneur_actif": "non"},
'debug': False, 'debug': False,
'id': 1, 'id': 1,
'mode': 'normal', 'mode': 'normal',
@ -426,6 +440,7 @@ async def test_servermodel_filter_get_one_value():
async def test_servermodel_filter_configure(): async def test_servermodel_filter_configure():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -438,7 +453,7 @@ async def test_servermodel_filter_configure():
fake_context, fake_context,
session_id=session_id, session_id=session_id,
action='modify', action='modify',
name='general.mode_conteneur_actif', name='creole.general.mode_conteneur_actif',
value='oui') value='oui')
list_result = await dispatcher.call('v1', list_result = await dispatcher.call('v1',
'session.servermodel.list', 'session.servermodel.list',
@ -447,8 +462,8 @@ async def test_servermodel_filter_configure():
'session.servermodel.get', 'session.servermodel.get',
fake_context, fake_context,
session_id=session_id, session_id=session_id,
name="general.mode_conteneur_actif") name="creole.general.mode_conteneur_actif")
assert values == {'content': {"general.mode_conteneur_actif": "oui"}, assert values == {'content': {"creole.general.mode_conteneur_actif": "oui"},
'debug': False, 'debug': False,
'id': 1, 'id': 1,
'mode': 'normal', 'mode': 'normal',
@ -462,6 +477,7 @@ async def test_servermodel_filter_configure():
async def test_servermodel_filter_validate(): async def test_servermodel_filter_validate():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
session = await dispatcher.call('v1', session = await dispatcher.call('v1',
@ -479,6 +495,7 @@ async def test_servermodel_filter_validate():
async def test_servermodel_stop(): async def test_servermodel_stop():
fake_context = get_fake_context('session') fake_context = get_fake_context('session')
config_module = dispatcher.get_service('config') config_module = dispatcher.get_service('config')
config_module.cache_root_path = 'tests/data'
if not config_module.servermodel: if not config_module.servermodel:
await config_module.on_join(fake_context) await config_module.on_join(fake_context)
assert not await dispatcher.call('v1', assert not await dispatcher.call('v1',