update tests
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -66,22 +66,117 @@ async def onjoin(source=True):
|
||||
)
|
||||
|
||||
|
||||
INTERNAL_SOURCE = {'source_name': 'internal', 'source_directory': '/srv/risotto/seed/internal'}
|
||||
TEST_SOURCE = {'source_name': 'test', 'source_directory': 'tests/data'}
|
||||
|
||||
|
||||
##############################################################################################################################
|
||||
# Source / Release
|
||||
##############################################################################################################################
|
||||
@pytest.mark.asyncio
|
||||
async def test_on_join():
|
||||
async def test_source_on_join():
|
||||
# onjoin must create internal source
|
||||
sources = [INTERNAL_SOURCE]
|
||||
await onjoin(False)
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.list',
|
||||
fake_context,
|
||||
) == sources
|
||||
await delete_session()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_source_create():
|
||||
sources = [INTERNAL_SOURCE, TEST_SOURCE]
|
||||
await onjoin()
|
||||
config_module = dispatcher.get_service('config')
|
||||
assert list(config_module.servermodel.keys()) == ['last_base']
|
||||
assert list(config_module.server) == []
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.list',
|
||||
fake_context,
|
||||
) == sources
|
||||
await delete_session()
|
||||
# FIXME {source|release}.list {source|release}.describe {source|release}.delete, ...
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_source_describe():
|
||||
await onjoin()
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.describe',
|
||||
fake_context,
|
||||
source_name='internal',
|
||||
) == INTERNAL_SOURCE
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.describe',
|
||||
fake_context,
|
||||
source_name=SOURCE_NAME,
|
||||
) == TEST_SOURCE
|
||||
await delete_session()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_release_internal_list():
|
||||
releases = [{'release_distribution': 'last',
|
||||
'release_name': 'none',
|
||||
'source_name': 'internal'}]
|
||||
|
||||
await onjoin()
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.release.list',
|
||||
fake_context,
|
||||
source_name='internal',
|
||||
) == releases
|
||||
await delete_session()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_release_list():
|
||||
releases = [{'release_distribution': 'last',
|
||||
'release_name': '1',
|
||||
'source_name': 'test'}]
|
||||
|
||||
await onjoin()
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.release.list',
|
||||
fake_context,
|
||||
source_name='test',
|
||||
) == releases
|
||||
await delete_session()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_release_describe():
|
||||
|
||||
await onjoin()
|
||||
fake_context = get_fake_context('config')
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.release.describe',
|
||||
fake_context,
|
||||
source_name='internal',
|
||||
release_distribution='last',
|
||||
) == {'release_distribution': 'last',
|
||||
'release_name': 'none',
|
||||
'source_name': 'internal'}
|
||||
assert await dispatcher.call('v1',
|
||||
'setting.source.release.describe',
|
||||
fake_context,
|
||||
source_name='test',
|
||||
release_distribution='last',
|
||||
) == {'release_distribution': 'last',
|
||||
'release_name': '1',
|
||||
'source_name': 'test'}
|
||||
await delete_session()
|
||||
|
||||
|
||||
##############################################################################################################################
|
||||
# Servermodel
|
||||
##############################################################################################################################
|
||||
async def create_servermodel(name=SERVERMODEL_NAME,
|
||||
parents_name=['base'],
|
||||
):
|
||||
@ -97,9 +192,6 @@ async def create_servermodel(name=SERVERMODEL_NAME,
|
||||
)
|
||||
|
||||
|
||||
###################################################################################################################################
|
||||
# Servermodel
|
||||
###################################################################################################################################
|
||||
@pytest.mark.asyncio
|
||||
async def test_servermodel_created():
|
||||
await onjoin()
|
||||
@ -111,28 +203,6 @@ async def test_servermodel_created():
|
||||
assert not list(await config_module.servermodel['last_base'].config.parents())
|
||||
assert len(list(await config_module.servermodel['last_sm1'].config.parents())) == 1
|
||||
await delete_session()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_servermodel_created():
|
||||
await onjoin()
|
||||
config_module = dispatcher.get_service('config')
|
||||
fake_context = get_fake_context('config')
|
||||
#
|
||||
assert list(config_module.servermodel) == ['last_base']
|
||||
await dispatcher.call('v1',
|
||||
'setting.servermodel.create',
|
||||
fake_context,
|
||||
servermodel_name='sm1',
|
||||
servermodel_description='servermodel 1',
|
||||
parents_name=['base'],
|
||||
source_name=SOURCE_NAME,
|
||||
release_distribution='last',
|
||||
)
|
||||
assert list(config_module.servermodel) == ['last_base', 'last_sm1']
|
||||
assert not list(await config_module.servermodel['last_base'].config.parents())
|
||||
assert len(list(await config_module.servermodel['last_sm1'].config.parents())) == 1
|
||||
await delete_session()
|
||||
#
|
||||
#
|
||||
#@pytest.mark.asyncio
|
||||
@ -301,9 +371,9 @@ async def test_servermodel_created():
|
||||
## await delete_session()
|
||||
|
||||
|
||||
###################################################################################################################################
|
||||
##############################################################################################################################
|
||||
# Server
|
||||
###################################################################################################################################
|
||||
##############################################################################################################################
|
||||
@pytest.mark.asyncio
|
||||
async def test_server_created_base():
|
||||
await onjoin()
|
||||
|
Reference in New Issue
Block a user