reworks on tests

This commit is contained in:
Emmanuel Garette 2019-12-16 17:14:50 +01:00
parent f0042f2a37
commit 10969ab1e0
9 changed files with 84 additions and 71 deletions

View File

@ -9,7 +9,7 @@ pattern: rpc
public: true public: true
parameters: parameters:
servermodelid: servermodel_id:
type: Number type: Number
shortarg: s shortarg: s
description: Identifiant du modèle de serveur à récupérer. description: Identifiant du modèle de serveur à récupérer.

View File

@ -0,0 +1,24 @@
---
uri: source.release.create
description: |
Créer une version.
pattern: rpc
public: false
parameters:
source_id:
type: Number
shortarg: i
description: ID de la source.
release_name:
type: String
shortarg: n
description: |
Nom de la version.
response:
type: 'Release'
description: Information sur la version.

View File

@ -27,5 +27,4 @@ required:
- servermodelname - servermodelname
- servermodeldescription - servermodeldescription
- servermodelsubreleaseid - servermodelsubreleaseid
- sourceid
- subreleasename - subreleasename

View File

@ -3,16 +3,16 @@ title: ServermodelSource
type: object type: object
description: Description de la source. description: Description de la source.
properties: properties:
sourceid: source_id:
type: number type: number
description: ID de la source. description: ID de la source.
sourcename: source_name:
type: string type: string
description: Nom de la source. description: Nom de la source.
sourceurl: source_url:
type: string type: string
description: URL de la source. description: URL de la source.
required: required:
- sourceid - source_id
- sourcename - source_name
- sourceurl - source_url

View File

@ -250,7 +250,7 @@ class Dispatcher(register.RegisterDispatcher, CallDispatcher, PublishDispatcher)
except AttributeError: except AttributeError:
if DEBUG: if DEBUG:
print_exc() print_exc()
raise AttributeError(_(f'unknown parameter "{key}"')) raise ValueError(_(f'unknown parameter "{key}"'))
# check mandatories options # check mandatories options
config.property.read_only() config.property.read_only()
mandatories = list(config.value.mandatory()) mandatories = list(config.value.mandatory())

View File

@ -280,7 +280,7 @@ class Risotto(Controller):
self.load_server(risotto_context, self.load_server(risotto_context,
server_id, server_id,
servername, servername,
servermodel_id) servermodelid)
@register('v1.server.deleted') @register('v1.server.deleted')
async def server_deleted(self, async def server_deleted(self,

View File

@ -137,7 +137,7 @@ class Risotto(Controller):
return [dict(r) for r in servermodels] return [dict(r) for r in servermodels]
@register('v1.servermodel.describe', None) @register('v1.servermodel.describe', None)
async def servermodel_describe(self, inheritance, creolefuncs, servermodelid, schema, conffiles, resolvdepends, probes): async def servermodel_describe(self, inheritance, creolefuncs, servermodel_id, schema, conffiles, resolvdepends, probes):
schema = """<?xml version='1.0' encoding='UTF-8'?> schema = """<?xml version='1.0' encoding='UTF-8'?>
<creole> <creole>
<family name="containers"> <family name="containers">
@ -188,4 +188,4 @@ class Risotto(Controller):
<separators/> <separators/>
</family> </family>
</creole>""" </creole>"""
return {'servermodelid': 1, 'servermodelname': 'name', 'servermodeldescription': 'description', 'subreleasename': 'name', 'source_id': 1, 'schema': schema, 'creolefuncs': ''} return {'servermodel_id': 1, 'servermodel_name': 'name', 'servermodel_description': 'description', 'release_id': 1, 'schema': schema, 'creolefuncs': ''}

View File

@ -3,21 +3,19 @@ from risotto.register import register
class Risotto(Controller): class Risotto(Controller):
@register('v1.servermodel.list', None) @register('v1.servermodel.list', None)
async def servermodel_list(self, sourceid): async def servermodel_list(self, source_id):
return [{'servermodelid': 1, return [{'servermodel_id': 1,
'servermodelname': 'name1', 'servermodel_name': 'name1',
'subreleasename': 'name1', 'release_id': 1,
'sourceid': 1, 'servermodel_description': 'description1'},
'servermodeldescription': 'description1'}, {'servermodel_id': 2,
{'servermodelid': 2, 'servermodel_name': 'name2',
'servermodelname': 'name2', 'release_id': 2,
'subreleasename': 'name2', 'servermodel_description': 'description2',
'sourceid': 2, 'servermodel_parents_id': [1]}]
'servermodeldescription': 'description2',
'servermodelparentsid': [1]}]
@register('v1.servermodel.describe', None) @register('v1.servermodel.describe', None)
async def servermodel_describe(self, inheritance, creolefuncs, servermodelid, schema, conffiles, resolvdepends, probes): async def servermodel_describe(self, inheritance, creolefuncs, servermodel_id, schema, conffiles, resolvdepends, probes):
schema = """<?xml version='1.0' encoding='UTF-8'?> schema = """<?xml version='1.0' encoding='UTF-8'?>
<creole> <creole>
<family name="containers"> <family name="containers">
@ -68,4 +66,4 @@ class Risotto(Controller):
<separators/> <separators/>
</family> </family>
</creole>""" </creole>"""
return {'servermodelid': 1, 'servermodelname': 'name', 'servermodeldescription': 'description', 'subreleasename': 'name', 'sourceid': 1, 'schema': schema, 'creolefuncs': ''} return {'servermodel_id': 1, 'servermodel_name': 'name', 'servermodel_description': 'description', 'release_id': 1, 'schema': schema, 'creolefuncs': ''}

View File

@ -105,11 +105,10 @@ async def test_servermodel_created():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.created', 'servermodel.created',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodeldescription='name3', servermodel_description='name3',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_name='name3')
servermodelname='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(config_module.servermodel[3].config.parents())
@ -124,12 +123,11 @@ async def test_servermodel_herited_created():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.created', 'servermodel.created',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodelname='name3', servermodel_name='name3',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name3',
servermodeldescription='name3', servermodel_parents_id=[1])
servermodelparentsid=[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(config_module.servermodel[3].config.parents())) == 1
@ -144,12 +142,11 @@ async def test_servermodel_multi_herited_created():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.created', 'servermodel.created',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodelname='name3', servermodel_name='name3',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name3',
servermodeldescription='name3', servermodel_parents_id=[1, 2])
servermodelparentsid=[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(config_module.servermodel[3].config.parents())) == 2
@ -164,12 +161,11 @@ async def test_servermodel_updated_not_exists():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.updated', 'servermodel.updated',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodelname='name3', servermodel_name='name3',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name3',
servermodeldescription='name3', servermodel_parents_id=[1, 2])
servermodelparentsid=[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(config_module.servermodel[3].config.parents())) == 2
@ -193,11 +189,10 @@ async def test_servermodel_updated1():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.updated', 'servermodel.updated',
fake_context, fake_context,
servermodelid=1, servermodel_id=1,
servermodelname='name1-1', servermodel_name='name1-1',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name1-1')
servermodeldescription='name1-1')
assert set(config_module.servermodel) == {1, 2} assert set(config_module.servermodel) == {1, 2}
assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1' assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1'
assert metaconfig1 != config_module.servermodel[1] assert metaconfig1 != config_module.servermodel[1]
@ -226,12 +221,11 @@ async def test_servermodel_updated2():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.created', 'servermodel.created',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodelname='name3', servermodel_name='name3',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name3',
servermodeldescription='name3', servermodel_parents_id=[1])
servermodelparentsid=[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(config_module.servermodel[3].config.parents())) == 1
assert config_module.servermodel[3].information.get('servermodel_name') == 'name3' assert config_module.servermodel[3].information.get('servermodel_name') == 'name3'
@ -241,12 +235,11 @@ async def test_servermodel_updated2():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.updated', 'servermodel.updated',
fake_context, fake_context,
servermodelid=3, servermodel_id=3,
servermodelname='name3-1', servermodel_name='name3-1',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name3-1',
servermodeldescription='name3-1', servermodel_parents_id=[1, 2])
servermodelparentsid=[1, 2])
assert list(config_module.servermodel) == [1, 2, 3] assert list(config_module.servermodel) == [1, 2, 3]
assert config_module.servermodel[3].information.get('servermodel_name') == 'name3-1' assert config_module.servermodel[3].information.get('servermodel_name') == 'name3-1'
assert len(list(mixconfig1.config.list())) == 2 assert len(list(mixconfig1.config.list())) == 2
@ -267,11 +260,10 @@ async def test_servermodel_updated_config():
await dispatcher.publish('v1', await dispatcher.publish('v1',
'servermodel.updated', 'servermodel.updated',
fake_context, fake_context,
servermodelid=1, servermodel_id=1,
servermodelname='name1-1', servermodel_name='name1-1',
subreleasename='2.7.0', release_id=1,
sourceid=1, servermodel_description='name1-1')
servermodeldescription='name1-1')
assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui' assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'