# Path: lamvery/actions/configure.py
# class ConfigureAction(BaseAction):
# 
#     def __init__(self, args):
#         super(ConfigureAction, self).__init__(args)
# 
#     def action(self):
#         func_name = self._config.get_function_name()
#         local_conf = self._config.get_configuration()
#         client = self.get_lambda_client()
#         remote_conf = client.get_function_conf(func_name)
#         vpc_config = self._config.get_vpc_configuration()
# 
#         if len(remote_conf) > 0:
#             self._print_diff(
#                 prefix='[Function]',
#                 remote=remote_conf, local=local_conf, keys=CONF_DIFF_KEYS)
# 
#             if vpc_config is not None:
#                 self._print_diff(
#                     prefix='[Function]',
#                     remote=remote_conf.get('VpcConfig', {}), local=vpc_config, keys=VPC_DIFF_KEYS)
# 
#             client.update_function_conf(local_conf)
#         else:
#             msg = '"{}" function does not exist. Please `deploy` first.'.format(func_name)
#             raise Exception(msg)


from unittest import TestCase
from nose.tools import raises
from mock import Mock, patch
from lamvery.actions.configure import ConfigureAction
# -*- coding: utf-8 -*-




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.dry_run = True
    return args


class ConfigureActionTestCase(TestCase):

    @raises(Exception)
    def test_action_not_exists(self):
        with patch('lamvery.actions.base.LambdaClient') as c:
            action = ConfigureAction(default_args())
            action._print_conf_diff = Mock()
            c.get_function_conf = Mock(return_value={})
            action.action()

    def test_action(self):
        c = Mock()
        c.get_function_conf = Mock(return_value={'foo': 'bar'})

        # Dry run

# Path: lamvery/actions/configure.py
# class ConfigureAction(BaseAction):
# 
#     def __init__(self, args):
#         super(ConfigureAction, self).__init__(args)
# 
#     def action(self):
#         func_name = self._config.get_function_name()
#         local_conf = self._config.get_configuration()
#         client = self.get_lambda_client()
#         remote_conf = client.get_function_conf(func_name)
#         vpc_config = self._config.get_vpc_configuration()
# 
#         if len(remote_conf) > 0:
#             self._print_diff(
#                 prefix='[Function]',
#                 remote=remote_conf, local=local_conf, keys=CONF_DIFF_KEYS)
# 
#             if vpc_config is not None:
#                 self._print_diff(
#                     prefix='[Function]',
#                     remote=remote_conf.get('VpcConfig', {}), local=vpc_config, keys=VPC_DIFF_KEYS)
# 
#             client.update_function_conf(local_conf)
#         else:
#             msg = '"{}" function does not exist. Please `deploy` first.'.format(func_name)
#             raise Exception(msg)


# Path: tests/lamvery/actions/configure_test.py
from unittest import TestCase
from nose.tools import raises
from mock import Mock, patch
from lamvery.actions.configure import ConfigureAction

# -*- coding: utf-8 -*-




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.dry_run = True
    return args


class ConfigureActionTestCase(TestCase):

    @raises(Exception)
    def test_action_not_exists(self):
        with patch('lamvery.actions.base.LambdaClient') as c:
            action = ConfigureAction(default_args())
            action._print_conf_diff = Mock()
            c.get_function_conf = Mock(return_value={})
            action.action()

    def test_action(self):
        c = Mock()
        c.get_function_conf = Mock(return_value={'foo': 'bar'})

        # Dry run

        action = ConfigureAction(default_args())