update tests
This commit is contained in:
parent
1d25d3a582
commit
50aa8019ab
|
@ -5,6 +5,10 @@ from .context import Context
|
|||
class Controller:
|
||||
"""Common controller used to add a service in Risotto
|
||||
"""
|
||||
def __init__(self,
|
||||
test: bool):
|
||||
pass
|
||||
|
||||
async def call(self,
|
||||
uri: str,
|
||||
risotto_context: Context,
|
||||
|
|
|
@ -218,11 +218,11 @@ class RegisterDispatcher:
|
|||
dico['notification'] = notification
|
||||
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
|
||||
"""
|
||||
try:
|
||||
self.injected_self[module_name] = module.Risotto()
|
||||
self.injected_self[module_name] = module.Risotto(test)
|
||||
except AttributeError as err:
|
||||
raise RegistrationError(_(f'unable to register the module {module_name}, this module must have Risotto class'))
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ from ..dispatcher import dispatcher
|
|||
|
||||
|
||||
def load_services(modules=None,
|
||||
validate: bool=True):
|
||||
validate: bool=True,
|
||||
test: bool=False):
|
||||
abs_here = dirname(abspath(__file__))
|
||||
here = basename(abs_here)
|
||||
module = basename(dirname(abs_here))
|
||||
|
@ -14,6 +15,6 @@ def load_services(modules=None,
|
|||
for filename in modules:
|
||||
absfilename = join(abs_here, filename)
|
||||
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:
|
||||
dispatcher.validate()
|
||||
|
|
|
@ -19,15 +19,18 @@ from ...logger import log
|
|||
|
||||
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')
|
||||
for dirname in [self.cache_root_path, DATABASE_DIR]:
|
||||
if not isdir(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.servermodel = {}
|
||||
self.server = {}
|
||||
super().__init__()
|
||||
super().__init__(test)
|
||||
|
||||
async def on_join(self,
|
||||
risotto_context: Context) -> None:
|
||||
|
@ -80,28 +83,7 @@ class Risotto(Controller):
|
|||
None,
|
||||
f'Load servermodel {servermodel_name} ({servermodel_id})')
|
||||
|
||||
# use file in cache if found, otherwise retrieve it in servermodel context
|
||||
# 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
|
||||
# use file in cache
|
||||
with open(cache_file) as fileio:
|
||||
xmlroot = parse(fileio).getroot()
|
||||
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']:
|
||||
config = self.server[server_id]['server']
|
||||
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,
|
||||
session_id=await config.config.name())
|
||||
# delete metaconfig
|
||||
|
@ -341,46 +323,46 @@ class Risotto(Controller):
|
|||
delete_session(storage=self.save_storage,
|
||||
session_id=await metaconfig.config.name())
|
||||
return children
|
||||
|
||||
@register('v1.servermodel.updated')
|
||||
async def servermodel_updated(self,
|
||||
risotto_context: Context,
|
||||
servermodel_id: int,
|
||||
servermodel_name: str,
|
||||
servermodel_parents_id: List[int]) -> None:
|
||||
log.info_msg(risotto_context,
|
||||
None,
|
||||
f'Reload servermodel {servermodel_name} ({servermodel_id})')
|
||||
# unlink cache to force download new aggregated file
|
||||
cache_file = join(self.cache_root_path, str(servermodel_id)+".xml")
|
||||
if isfile(cache_file):
|
||||
unlink(cache_file)
|
||||
|
||||
# store all informations
|
||||
if servermodel_id in self.servermodel:
|
||||
old_values = await self.servermodel[servermodel_id].value.exportation()
|
||||
old_permissives = await self.servermodel[servermodel_id].permissive.exportation()
|
||||
old_properties = await self.servermodel[servermodel_id].property.exportation()
|
||||
children = await self.servermodel_delete(servermodel_id)
|
||||
else:
|
||||
old_values = None
|
||||
|
||||
# create new one
|
||||
await self.load_and_link_servermodel(risotto_context,
|
||||
servermodel_id,
|
||||
servermodel_name,
|
||||
servermodel_parents_id)
|
||||
|
||||
# migrates informations
|
||||
if old_values is not None:
|
||||
await self.servermodel[servermodel_id].value.importation(old_values)
|
||||
await self.servermodel[servermodel_id].permissive.importation(old_permissives)
|
||||
await self.servermodel[servermodel_id].property.importation(old_properties)
|
||||
for child in children:
|
||||
await self.servermodel_legacy(risotto_context,
|
||||
await child.information.get('servermodel_name'),
|
||||
await child.information.get('servermodel_id'),
|
||||
servermodel_id)
|
||||
#
|
||||
# @register('v1.servermodel.updated')
|
||||
# async def servermodel_updated(self,
|
||||
# risotto_context: Context,
|
||||
# servermodel_id: int,
|
||||
# servermodel_name: str,
|
||||
# servermodel_parents_id: List[int]) -> None:
|
||||
# log.info_msg(risotto_context,
|
||||
# None,
|
||||
# f'Reload servermodel {servermodel_name} ({servermodel_id})')
|
||||
# # unlink cache to force download new aggregated file
|
||||
# cache_file = join(self.cache_root_path, str(servermodel_id)+".xml")
|
||||
# if isfile(cache_file):
|
||||
# unlink(cache_file)
|
||||
#
|
||||
# # store all informations
|
||||
# if servermodel_id in self.servermodel:
|
||||
# old_values = await self.servermodel[servermodel_id].value.exportation()
|
||||
# old_permissives = await self.servermodel[servermodel_id].permissive.exportation()
|
||||
# old_properties = await self.servermodel[servermodel_id].property.exportation()
|
||||
# children = await self.servermodel_delete(servermodel_id)
|
||||
# else:
|
||||
# old_values = None
|
||||
#
|
||||
# # create new one
|
||||
# await self.load_and_link_servermodel(risotto_context,
|
||||
# servermodel_id,
|
||||
# servermodel_name,
|
||||
# servermodel_parents_id)
|
||||
#
|
||||
# # migrates informations
|
||||
# if old_values is not None:
|
||||
# await self.servermodel[servermodel_id].value.importation(old_values)
|
||||
# await self.servermodel[servermodel_id].permissive.importation(old_permissives)
|
||||
# await self.servermodel[servermodel_id].property.importation(old_properties)
|
||||
# for child in children:
|
||||
# await self.servermodel_legacy(risotto_context,
|
||||
# await child.information.get('servermodel_name'),
|
||||
# await child.information.get('servermodel_id'),
|
||||
# servermodel_id)
|
||||
|
||||
@register('v1.config.configuration.server.get', None)
|
||||
async def get_configuration(self,
|
||||
|
|
|
@ -41,7 +41,7 @@ class Risotto(Controller):
|
|||
'server_servermodel_id': server_servermodel_id}
|
||||
|
||||
@register('v1.server.describe', None, database=True)
|
||||
async def server_create(self,
|
||||
async def server_describe(self,
|
||||
risotto_context: Context,
|
||||
server_name: str) -> Dict:
|
||||
sql = '''
|
||||
|
|
|
@ -16,7 +16,8 @@ from ...dispatcher import dispatcher
|
|||
|
||||
|
||||
class Risotto(Controller):
|
||||
def __init__(self):
|
||||
def __init__(self,
|
||||
test):
|
||||
self.modify_storage = Storage(engine='dictionary')
|
||||
|
||||
def get_storage(self,
|
||||
|
@ -221,7 +222,7 @@ class Risotto(Controller):
|
|||
type)
|
||||
info = self.format_session(session_id, session)
|
||||
if name is not None:
|
||||
content = {name: await session['option'].option(name).value.get()}
|
||||
content = {name: await session['config'].option(name).value.get()}
|
||||
else:
|
||||
content = await session['option'].value.dict(fullpath=True,
|
||||
leader_to_list=True)
|
||||
|
|
|
@ -44,7 +44,7 @@ class Storage(object):
|
|||
break
|
||||
await config.property.read_write()
|
||||
# set the default owner
|
||||
self.set_owner(config,
|
||||
await self.set_owner(config,
|
||||
username)
|
||||
|
||||
# store it
|
||||
|
@ -113,10 +113,10 @@ class StorageServer(Storage):
|
|||
server_id: int):
|
||||
return f'std_{server_id}'
|
||||
|
||||
def set_owner(self,
|
||||
async def set_owner(self,
|
||||
config: Config,
|
||||
username: str):
|
||||
config.owner.set(username)
|
||||
await config.owner.set(username)
|
||||
|
||||
|
||||
class StorageServermodel(Storage):
|
||||
|
@ -124,10 +124,10 @@ class StorageServermodel(Storage):
|
|||
server_id: int):
|
||||
return f'v_{server_id}'
|
||||
|
||||
def set_owner(self,
|
||||
async def set_owner(self,
|
||||
config: Config,
|
||||
username: str):
|
||||
config.owner.set('servermodel_' + username)
|
||||
await config.owner.set('servermodel_' + username)
|
||||
|
||||
|
||||
storage_server = StorageServer()
|
||||
|
|
|
@ -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,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,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>
|
|
@ -5,4 +5,4 @@ from risotto.register import register
|
|||
class Risotto(Controller):
|
||||
@register('v1.server.list', None)
|
||||
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}]
|
||||
|
|
|
@ -13,63 +13,3 @@ class Risotto(Controller):
|
|||
'release_id': 2,
|
||||
'servermodel_description': 'description2',
|
||||
'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}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
from tiramisu import Storage
|
||||
from risotto.config import DATABASE_DIR
|
||||
|
||||
|
||||
STORAGE = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test')
|
|
@ -1,20 +1,20 @@
|
|||
from importlib import import_module
|
||||
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.services import load_services
|
||||
from risotto.dispatcher import dispatcher
|
||||
from risotto.config import DATABASE_DIR
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
load_services(['config'],
|
||||
validate=False)
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test')
|
||||
dispatcher.set_module('server', import_module(f'.server', 'fake_services'))
|
||||
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'))
|
||||
config_module.save_storage = STORAGE
|
||||
dispatcher.set_module('server', import_module(f'.server', 'fake_services'), True)
|
||||
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'), True)
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
@ -45,17 +45,19 @@ async def test_on_join():
|
|||
assert config_module.server == {}
|
||||
#
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
assert list(config_module.servermodel.keys()) == [1, 2]
|
||||
assert list(config_module.server) == [3]
|
||||
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
|
||||
async def test_server_created():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.server) == [3]
|
||||
|
@ -63,18 +65,19 @@ async def test_server_created():
|
|||
'server.created',
|
||||
fake_context,
|
||||
server_id=4,
|
||||
servername='name3',
|
||||
serverdescription='description3',
|
||||
servermodelid=2)
|
||||
server_name='name3',
|
||||
server_description='description3',
|
||||
server_servermodel_id=2)
|
||||
assert list(config_module.server) == [3, 4]
|
||||
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
|
||||
async def test_server_deleted():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.server) == [3]
|
||||
|
@ -82,9 +85,9 @@ async def test_server_deleted():
|
|||
'server.created',
|
||||
fake_context,
|
||||
server_id=4,
|
||||
servername='name4',
|
||||
serverdescription='description4',
|
||||
servermodelid=2)
|
||||
server_name='name4',
|
||||
server_description='description4',
|
||||
server_servermodel_id=2)
|
||||
assert list(config_module.server) == [3, 4]
|
||||
await dispatcher.publish('v1',
|
||||
'server.deleted',
|
||||
|
@ -97,6 +100,7 @@ async def test_server_deleted():
|
|||
async def test_servermodel_created():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
|
@ -110,13 +114,14 @@ async def test_servermodel_created():
|
|||
release_id=1,
|
||||
servermodel_name='name3')
|
||||
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
|
||||
async def test_servermodel_herited_created():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
|
@ -129,13 +134,14 @@ async def test_servermodel_herited_created():
|
|||
servermodel_description='name3',
|
||||
servermodel_parents_id=[1])
|
||||
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
|
||||
async def test_servermodel_multi_herited_created():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
|
@ -148,136 +154,141 @@ async def test_servermodel_multi_herited_created():
|
|||
servermodel_description='name3',
|
||||
servermodel_parents_id=[1, 2])
|
||||
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
|
||||
async def test_servermodel_updated_not_exists():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
await config_module.on_join(fake_context)
|
||||
#@pytest.mark.asyncio
|
||||
#async def test_servermodel_updated_not_exists():
|
||||
# config_module = dispatcher.get_service('config')
|
||||
# fake_context = get_fake_context('config')
|
||||
# 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',
|
||||
# 'servermodel.updated',
|
||||
# fake_context,
|
||||
# servermodel_id=3,
|
||||
# servermodel_name='name3',
|
||||
# release_id=1,
|
||||
# servermodel_description='name3',
|
||||
# servermodel_parents_id=[1, 2])
|
||||
# assert list(config_module.servermodel) == [1, 2, 3]
|
||||
# assert len(list(await config_module.servermodel[3].config.parents())) == 2
|
||||
#
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
await dispatcher.publish('v1',
|
||||
'servermodel.updated',
|
||||
fake_context,
|
||||
servermodel_id=3,
|
||||
servermodel_name='name3',
|
||||
release_id=1,
|
||||
servermodel_description='name3',
|
||||
servermodel_parents_id=[1, 2])
|
||||
assert list(config_module.servermodel) == [1, 2, 3]
|
||||
assert len(list(config_module.servermodel[3].config.parents())) == 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_servermodel_updated1():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
metaconfig1 = config_module.servermodel[1]
|
||||
metaconfig2 = config_module.servermodel[2]
|
||||
mixconfig1 = next(metaconfig1.config.list())
|
||||
mixconfig2 = next(metaconfig2.config.list())
|
||||
assert len(list(metaconfig1.config.parents())) == 0
|
||||
assert len(list(metaconfig2.config.parents())) == 1
|
||||
assert len(list(mixconfig1.config.list())) == 1
|
||||
assert len(list(mixconfig2.config.list())) == 0
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_servermodel_updated1():
|
||||
# config_module = dispatcher.get_service('config')
|
||||
# fake_context = get_fake_context('config')
|
||||
# config_module.cache_root_path = 'tests/data'
|
||||
# await config_module.on_join(fake_context)
|
||||
# #
|
||||
# assert list(config_module.servermodel) == [1, 2]
|
||||
# metaconfig1 = config_module.servermodel[1]
|
||||
# metaconfig2 = config_module.servermodel[2]
|
||||
# mixconfig1 = (await metaconfig1.config.list())[0]
|
||||
# mixconfig2 = (await metaconfig2.config.list())[0]
|
||||
# assert len(list(await metaconfig1.config.parents())) == 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
|
||||
# #
|
||||
# await dispatcher.publish('v1',
|
||||
# 'servermodel.updated',
|
||||
# fake_context,
|
||||
# servermodel_id=1,
|
||||
# servermodel_name='name1-1',
|
||||
# release_id=1,
|
||||
# servermodel_description='name1-1')
|
||||
# assert set(config_module.servermodel) == {1, 2}
|
||||
# assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1'
|
||||
# assert metaconfig1 != config_module.servermodel[1]
|
||||
# assert metaconfig2 == config_module.servermodel[2]
|
||||
# metaconfig1 = config_module.servermodel[1]
|
||||
# assert mixconfig1 != next(metaconfig1.config.list())
|
||||
# mixconfig1 = next(metaconfig1.config.list())
|
||||
# #
|
||||
# assert len(list(await metaconfig1.config.parents())) == 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
|
||||
#
|
||||
await dispatcher.publish('v1',
|
||||
'servermodel.updated',
|
||||
fake_context,
|
||||
servermodel_id=1,
|
||||
servermodel_name='name1-1',
|
||||
release_id=1,
|
||||
servermodel_description='name1-1')
|
||||
assert set(config_module.servermodel) == {1, 2}
|
||||
assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1'
|
||||
assert metaconfig1 != config_module.servermodel[1]
|
||||
assert metaconfig2 == config_module.servermodel[2]
|
||||
metaconfig1 = config_module.servermodel[1]
|
||||
assert mixconfig1 != next(metaconfig1.config.list())
|
||||
mixconfig1 = next(metaconfig1.config.list())
|
||||
#
|
||||
assert len(list(metaconfig1.config.parents())) == 0
|
||||
assert len(list(metaconfig2.config.parents())) == 1
|
||||
assert len(list(mixconfig1.config.list())) == 1
|
||||
assert len(list(mixconfig2.config.list())) == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_servermodel_updated2():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
await config_module.on_join(fake_context)
|
||||
# create a new servermodel
|
||||
assert list(config_module.servermodel) == [1, 2]
|
||||
mixconfig1 = next(config_module.servermodel[1].config.list())
|
||||
mixconfig2 = next(config_module.servermodel[2].config.list())
|
||||
assert len(list(mixconfig1.config.list())) == 1
|
||||
assert len(list(mixconfig2.config.list())) == 0
|
||||
await dispatcher.publish('v1',
|
||||
'servermodel.created',
|
||||
fake_context,
|
||||
servermodel_id=3,
|
||||
servermodel_name='name3',
|
||||
release_id=1,
|
||||
servermodel_description='name3',
|
||||
servermodel_parents_id=[1])
|
||||
assert list(config_module.servermodel) == [1, 2, 3]
|
||||
assert len(list(config_module.servermodel[3].config.parents())) == 1
|
||||
assert config_module.servermodel[3].information.get('servermodel_name') == 'name3'
|
||||
assert len(list(mixconfig1.config.list())) == 2
|
||||
assert len(list(mixconfig2.config.list())) == 0
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_servermodel_updated2():
|
||||
# config_module = dispatcher.get_service('config')
|
||||
# fake_context = get_fake_context('config')
|
||||
# config_module.cache_root_path = 'tests/data'
|
||||
# await config_module.on_join(fake_context)
|
||||
# # create a new servermodel
|
||||
# assert list(config_module.servermodel) == [1, 2]
|
||||
# mixconfig1 = next(config_module.servermodel[1].config.list())
|
||||
# mixconfig2 = next(config_module.servermodel[2].config.list())
|
||||
# assert len(list(mixconfig1.config.list())) == 1
|
||||
# assert len(list(mixconfig2.config.list())) == 0
|
||||
# await dispatcher.publish('v1',
|
||||
# 'servermodel.created',
|
||||
# fake_context,
|
||||
# servermodel_id=3,
|
||||
# servermodel_name='name3',
|
||||
# release_id=1,
|
||||
# servermodel_description='name3',
|
||||
# servermodel_parents_id=[1])
|
||||
# assert list(config_module.servermodel) == [1, 2, 3]
|
||||
# assert len(list(await config_module.servermodel[3].config.parents())) == 1
|
||||
# assert await config_module.servermodel[3].information.get('servermodel_name') == 'name3'
|
||||
# assert len(list(await mixconfig1.config.list())) == 2
|
||||
# assert len(list(await mixconfig2.config.list())) == 0
|
||||
# #
|
||||
# await dispatcher.publish('v1',
|
||||
# 'servermodel.updated',
|
||||
# fake_context,
|
||||
# servermodel_id=3,
|
||||
# servermodel_name='name3-1',
|
||||
# release_id=1,
|
||||
# servermodel_description='name3-1',
|
||||
# servermodel_parents_id=[1, 2])
|
||||
# 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
|
||||
# assert len(list(mixconfig2.config.list())) == 1
|
||||
#
|
||||
await dispatcher.publish('v1',
|
||||
'servermodel.updated',
|
||||
fake_context,
|
||||
servermodel_id=3,
|
||||
servermodel_name='name3-1',
|
||||
release_id=1,
|
||||
servermodel_description='name3-1',
|
||||
servermodel_parents_id=[1, 2])
|
||||
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
|
||||
assert len(list(mixconfig2.config.list())) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_servermodel_updated_config():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
config_module.servermodel[1].property.read_write()
|
||||
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.set('oui')
|
||||
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
|
||||
#
|
||||
await dispatcher.publish('v1',
|
||||
'servermodel.updated',
|
||||
fake_context,
|
||||
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
|
||||
# async def test_servermodel_updated_config():
|
||||
# config_module = dispatcher.get_service('config')
|
||||
# fake_context = get_fake_context('config')
|
||||
# config_module.cache_root_path = 'tests/data'
|
||||
# await config_module.on_join(fake_context)
|
||||
# #
|
||||
# config_module.servermodel[1].property.read_write()
|
||||
# assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
# config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.set('oui')
|
||||
# assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
|
||||
# #
|
||||
# await dispatcher.publish('v1',
|
||||
# 'servermodel.updated',
|
||||
# fake_context,
|
||||
# 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
|
||||
async def test_server_configuration_get():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
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'
|
||||
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 config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
await config_module.server[3]['server_to_deploy'].property.read_write()
|
||||
assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui')
|
||||
assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
|
||||
assert await config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
#
|
||||
values = await dispatcher.call('v1',
|
||||
'config.configuration.server.get',
|
||||
|
@ -311,16 +322,17 @@ async def test_server_configuration_get():
|
|||
async def test_config_deployed():
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
await config_module.on_join(fake_context)
|
||||
#
|
||||
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'
|
||||
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 config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
await config_module.server[3]['server_to_deploy'].property.read_write()
|
||||
assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.set('oui')
|
||||
assert await config_module.server[3]['server_to_deploy'].option('creole.general.mode_conteneur_actif').value.get() == 'oui'
|
||||
assert await config_module.server[3]['server'].option('creole.general.mode_conteneur_actif').value.get() == 'non'
|
||||
values = await dispatcher.publish('v1',
|
||||
'config.configuration.server.deploy',
|
||||
fake_context,
|
||||
server_id=3)
|
||||
assert 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_to_deploy'].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'
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
from importlib import import_module
|
||||
import pytest
|
||||
from tiramisu import Storage
|
||||
from .storage import STORAGE
|
||||
from risotto.context import Context
|
||||
from risotto.services import load_services
|
||||
from risotto.dispatcher import dispatcher
|
||||
from risotto.config import DATABASE_DIR
|
||||
from risotto.services.session.storage import storage_server, storage_servermodel
|
||||
|
||||
|
||||
|
@ -18,11 +17,13 @@ def get_fake_context(module_name):
|
|||
|
||||
def setup_module(module):
|
||||
load_services(['config', 'session'],
|
||||
validate=False)
|
||||
validate=False,
|
||||
test=True)
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.save_storage = Storage(engine='sqlite3', dir_database=DATABASE_DIR, name='test')
|
||||
dispatcher.set_module('server', import_module(f'.server', 'fake_services'))
|
||||
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'))
|
||||
config_module.save_storage = STORAGE
|
||||
dispatcher.set_module('server', import_module(f'.server', 'fake_services'), True)
|
||||
dispatcher.set_module('servermodel', import_module(f'.servermodel', 'fake_services'), True)
|
||||
dispatcher.injected_self['servermodel'].cache_root_path = 'tests/data'
|
||||
|
||||
|
||||
def teardown_function(function):
|
||||
|
@ -35,6 +36,7 @@ def teardown_function(function):
|
|||
async def test_server_start():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
await dispatcher.call('v1',
|
||||
|
@ -47,6 +49,7 @@ async def test_server_start():
|
|||
async def test_server_list():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
assert not await dispatcher.call('v1',
|
||||
|
@ -65,6 +68,7 @@ async def test_server_list():
|
|||
async def test_server_filter_namespace():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -88,6 +92,7 @@ async def test_server_filter_namespace():
|
|||
async def test_server_filter_mode():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -112,6 +117,7 @@ async def test_server_filter_mode():
|
|||
async def test_server_filter_debug():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -137,6 +143,7 @@ async def test_server_filter_debug():
|
|||
async def test_server_filter_get():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -148,10 +155,8 @@ async def test_server_filter_get():
|
|||
'session.server.get',
|
||||
fake_context,
|
||||
session_id=session_id)
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "non",
|
||||
"general.master.master": [],
|
||||
"general.master.slave1": [],
|
||||
"general.master.slave2": []},
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "non",
|
||||
"creole.general.master.master": []},
|
||||
'debug': False,
|
||||
'id': 3,
|
||||
'mode': 'normal',
|
||||
|
@ -165,6 +170,7 @@ async def test_server_filter_get():
|
|||
async def test_server_filter_get_one_value():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -176,8 +182,8 @@ async def test_server_filter_get_one_value():
|
|||
'session.server.get',
|
||||
fake_context,
|
||||
session_id=session_id,
|
||||
name="general.mode_conteneur_actif")
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "non"},
|
||||
name="creole.general.mode_conteneur_actif")
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "non"},
|
||||
'debug': False,
|
||||
'id': 3,
|
||||
'mode': 'normal',
|
||||
|
@ -191,6 +197,7 @@ async def test_server_filter_get_one_value():
|
|||
async def test_server_filter_configure():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -203,7 +210,7 @@ async def test_server_filter_configure():
|
|||
fake_context,
|
||||
session_id=session_id,
|
||||
action='modify',
|
||||
name='general.mode_conteneur_actif',
|
||||
name='creole.general.mode_conteneur_actif',
|
||||
value='oui')
|
||||
list_result = await dispatcher.call('v1',
|
||||
'session.server.list',
|
||||
|
@ -212,8 +219,8 @@ async def test_server_filter_configure():
|
|||
'session.server.get',
|
||||
fake_context,
|
||||
session_id=session_id,
|
||||
name="general.mode_conteneur_actif")
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "oui"},
|
||||
name="creole.general.mode_conteneur_actif")
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "oui"},
|
||||
'debug': False,
|
||||
'id': 3,
|
||||
'mode': 'normal',
|
||||
|
@ -227,6 +234,7 @@ async def test_server_filter_configure():
|
|||
async def test_server_filter_validate():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -244,6 +252,7 @@ async def test_server_filter_validate():
|
|||
async def test_server_stop():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.server:
|
||||
await config_module.on_join(fake_context)
|
||||
assert not await dispatcher.call('v1',
|
||||
|
@ -271,6 +280,7 @@ async def test_server_stop():
|
|||
async def test_servermodel_start():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
await dispatcher.call('v1',
|
||||
|
@ -283,6 +293,7 @@ async def test_servermodel_start():
|
|||
async def test_servermodel_list():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
assert not await dispatcher.call('v1',
|
||||
|
@ -301,6 +312,7 @@ async def test_servermodel_list():
|
|||
async def test_servermodel_filter_namespace():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -324,6 +336,7 @@ async def test_servermodel_filter_namespace():
|
|||
async def test_servermodel_filter_mode():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -348,6 +361,7 @@ async def test_servermodel_filter_mode():
|
|||
async def test_servermodel_filter_debug():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -372,6 +386,7 @@ async def test_servermodel_filter_debug():
|
|||
async def test_servermodel_filter_get():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -383,10 +398,8 @@ async def test_servermodel_filter_get():
|
|||
'session.servermodel.get',
|
||||
fake_context,
|
||||
session_id=session_id)
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "non",
|
||||
"general.master.master": [],
|
||||
"general.master.slave1": [],
|
||||
"general.master.slave2": []},
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "non",
|
||||
"creole.general.master.master": []},
|
||||
'debug': False,
|
||||
'id': 1,
|
||||
'mode': 'normal',
|
||||
|
@ -400,6 +413,7 @@ async def test_servermodel_filter_get():
|
|||
async def test_servermodel_filter_get_one_value():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -411,8 +425,8 @@ async def test_servermodel_filter_get_one_value():
|
|||
'session.servermodel.get',
|
||||
fake_context,
|
||||
session_id=session_id,
|
||||
name="general.mode_conteneur_actif")
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "non"},
|
||||
name="creole.general.mode_conteneur_actif")
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "non"},
|
||||
'debug': False,
|
||||
'id': 1,
|
||||
'mode': 'normal',
|
||||
|
@ -426,6 +440,7 @@ async def test_servermodel_filter_get_one_value():
|
|||
async def test_servermodel_filter_configure():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -438,7 +453,7 @@ async def test_servermodel_filter_configure():
|
|||
fake_context,
|
||||
session_id=session_id,
|
||||
action='modify',
|
||||
name='general.mode_conteneur_actif',
|
||||
name='creole.general.mode_conteneur_actif',
|
||||
value='oui')
|
||||
list_result = await dispatcher.call('v1',
|
||||
'session.servermodel.list',
|
||||
|
@ -447,8 +462,8 @@ async def test_servermodel_filter_configure():
|
|||
'session.servermodel.get',
|
||||
fake_context,
|
||||
session_id=session_id,
|
||||
name="general.mode_conteneur_actif")
|
||||
assert values == {'content': {"general.mode_conteneur_actif": "oui"},
|
||||
name="creole.general.mode_conteneur_actif")
|
||||
assert values == {'content': {"creole.general.mode_conteneur_actif": "oui"},
|
||||
'debug': False,
|
||||
'id': 1,
|
||||
'mode': 'normal',
|
||||
|
@ -462,6 +477,7 @@ async def test_servermodel_filter_configure():
|
|||
async def test_servermodel_filter_validate():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
session = await dispatcher.call('v1',
|
||||
|
@ -479,6 +495,7 @@ async def test_servermodel_filter_validate():
|
|||
async def test_servermodel_stop():
|
||||
fake_context = get_fake_context('session')
|
||||
config_module = dispatcher.get_service('config')
|
||||
config_module.cache_root_path = 'tests/data'
|
||||
if not config_module.servermodel:
|
||||
await config_module.on_join(fake_context)
|
||||
assert not await dispatcher.call('v1',
|
||||
|
|
Loading…
Reference in New Issue