def test_containers_format_command(story): """ Ensures a simple resolve can be performed """ story_text = 'alpine echo msg:"foo"\n' story.context = {} story.app.services = { 'alpine': { ServiceConstants.config: { 'actions': { 'echo': { 'arguments': { 'msg': { 'type': 'string' } } } } } } } story.tree = storyscript.Api.loads(story_text).result()['tree'] assert Containers.format_command(story, story.line('1'), 'alpine', 'echo') == ['echo', '{"msg":"foo"}']
def test_format_command_no_args(logger, app, echo_service, echo_line): story = Story.story(app, logger, 'echo.story') app.services = echo_service echo_service['alpine'][ ServiceConstants.config]['actions']['echo']['arguments'] = None cmd = Containers.format_command(story, echo_line, 'alpine', 'echo') assert ['echo'] == cmd
def test_format_command_no_format(logger, app, echo_service, echo_line): story = Story.story(app, logger, 'echo.story') app.services = echo_service config = app.services['alpine'][ServiceConstants.config] config['actions']['echo']['format'] = None cmd = Containers.format_command(story, echo_line, 'alpine', 'echo') assert ['echo', '{"msg":"foo"}'] == cmd
def test_format_command_with_format(patch, logger, app, echo_service, echo_line): story = Story.story(app, logger, 'echo.story') patch.object(story, 'argument_by_name', return_value='asyncy') app.services = echo_service config = app.services['alpine'][ServiceConstants.config] config['actions']['echo']['format'] = 'echo {msg}' cmd = Containers.format_command(story, echo_line, 'alpine', 'echo') assert ['echo', 'asyncy'] == cmd
def test_containers_format_command_no_arguments(story): story_text = 'alpine echo\n' story.context = {} story.app.services = { 'alpine': { ServiceConstants.config: { 'actions': { 'echo': {} } } } } story.tree = storyscript.Api.loads(story_text).result()['tree'] assert Containers.format_command(story, story.line('1'), 'alpine', 'echo') == ['echo']
def test_containers_format_command_no_arguments(story): story_text = 'alpine echo\n' story.context = {} story.app.services = { 'alpine': { ServiceConstants.config: { 'actions': { 'echo': {} } } } } story.tree = Compiler.compile(Parser().parse(story_text))['tree'] assert Containers.format_command( story, story.line('1'), 'alpine', 'echo' ) == ['echo']
def test_format_command_no_spec(logger, app, echo_line): story = Story.story(app, logger, 'echo.story') app.services = {} with pytest.raises(ContainerSpecNotRegisteredError): Containers.format_command(story, echo_line, 'alpine', 'echo')
def test_format_command(logger, app, echo_service, echo_line): story = Story.story(app, logger, 'echo.story') app.services = echo_service cmd = Containers.format_command(story, echo_line, 'alpine', 'echo') assert ['echo', '{"msg":"foo"}'] == cmd