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
parameters:
servermodelid:
servermodel_id:
type: Number
shortarg: s
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
- servermodeldescription
- servermodelsubreleaseid
- sourceid
- subreleasename

View File

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

View File

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

View File

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

View File

@ -137,7 +137,7 @@ class Risotto(Controller):
return [dict(r) for r in servermodels]
@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'?>
<creole>
<family name="containers">
@ -188,4 +188,4 @@ class Risotto(Controller):
<separators/>
</family>
</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):
@register('v1.servermodel.list', None)
async def servermodel_list(self, sourceid):
return [{'servermodelid': 1,
'servermodelname': 'name1',
'subreleasename': 'name1',
'sourceid': 1,
'servermodeldescription': 'description1'},
{'servermodelid': 2,
'servermodelname': 'name2',
'subreleasename': 'name2',
'sourceid': 2,
'servermodeldescription': 'description2',
'servermodelparentsid': [1]}]
async def servermodel_list(self, source_id):
return [{'servermodel_id': 1,
'servermodel_name': 'name1',
'release_id': 1,
'servermodel_description': 'description1'},
{'servermodel_id': 2,
'servermodel_name': 'name2',
'release_id': 2,
'servermodel_description': 'description2',
'servermodel_parents_id': [1]}]
@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'?>
<creole>
<family name="containers">
@ -68,4 +66,4 @@ class Risotto(Controller):
<separators/>
</family>
</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',
'servermodel.created',
fake_context,
servermodelid=3,
servermodeldescription='name3',
subreleasename='2.7.0',
sourceid=1,
servermodelname='name3')
servermodel_id=3,
servermodel_description='name3',
release_id=1,
servermodel_name='name3')
assert list(config_module.servermodel) == [1, 2, 3]
assert not list(config_module.servermodel[3].config.parents())
@ -124,12 +123,11 @@ async def test_servermodel_herited_created():
await dispatcher.publish('v1',
'servermodel.created',
fake_context,
servermodelid=3,
servermodelname='name3',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name3',
servermodelparentsid=[1])
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
@ -144,12 +142,11 @@ async def test_servermodel_multi_herited_created():
await dispatcher.publish('v1',
'servermodel.created',
fake_context,
servermodelid=3,
servermodelname='name3',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name3',
servermodelparentsid=[1, 2])
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
@ -164,12 +161,11 @@ async def test_servermodel_updated_not_exists():
await dispatcher.publish('v1',
'servermodel.updated',
fake_context,
servermodelid=3,
servermodelname='name3',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name3',
servermodelparentsid=[1, 2])
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
@ -193,11 +189,10 @@ async def test_servermodel_updated1():
await dispatcher.publish('v1',
'servermodel.updated',
fake_context,
servermodelid=1,
servermodelname='name1-1',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name1-1')
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]
@ -226,12 +221,11 @@ async def test_servermodel_updated2():
await dispatcher.publish('v1',
'servermodel.created',
fake_context,
servermodelid=3,
servermodelname='name3',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name3',
servermodelparentsid=[1])
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'
@ -241,12 +235,11 @@ async def test_servermodel_updated2():
await dispatcher.publish('v1',
'servermodel.updated',
fake_context,
servermodelid=3,
servermodelname='name3-1',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name3-1',
servermodelparentsid=[1, 2])
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
@ -267,11 +260,10 @@ async def test_servermodel_updated_config():
await dispatcher.publish('v1',
'servermodel.updated',
fake_context,
servermodelid=1,
servermodelname='name1-1',
subreleasename='2.7.0',
sourceid=1,
servermodeldescription='name1-1')
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'