# Path: lamvery/actions/encrypt.py
# class EncryptAction(BaseAction):
# 
#     def __init__(self, args):
#         super(EncryptAction, self).__init__(args)
#         self._text = args.text
#         self._name = args.secret_name
#         self._store = args.store
# 
#     def action(self):
#         cipher_text = self.get_kms_client().encrypt(
#             self._config.get_secret().get('key_id'), self._text)
# 
#         if self._store:
#             self._config.store_secret(self._name, cipher_text)
#         else:
#             print(cipher_text)


from unittest import TestCase
from mock import Mock, patch
from lamvery.actions.encrypt import EncryptAction
# -*- coding: utf-8 -*-




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.text = 'foo'
    args.secret_name = 'bar'
    args.store = False
    return args


class EncryptActionTestCase(TestCase):

    def test_action(self):
        with patch('lamvery.actions.base.KmsClient'):
            args = default_args()
            action = EncryptAction(args)
            action._config = Mock()
            action.action()

            args.store = True

# Path: lamvery/actions/encrypt.py
# class EncryptAction(BaseAction):
# 
#     def __init__(self, args):
#         super(EncryptAction, self).__init__(args)
#         self._text = args.text
#         self._name = args.secret_name
#         self._store = args.store
# 
#     def action(self):
#         cipher_text = self.get_kms_client().encrypt(
#             self._config.get_secret().get('key_id'), self._text)
# 
#         if self._store:
#             self._config.store_secret(self._name, cipher_text)
#         else:
#             print(cipher_text)


# Path: tests/lamvery/actions/encrypt_test.py
from unittest import TestCase
from mock import Mock, patch
from lamvery.actions.encrypt import EncryptAction

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




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.text = 'foo'
    args.secret_name = 'bar'
    args.store = False
    return args


class EncryptActionTestCase(TestCase):

    def test_action(self):
        with patch('lamvery.actions.base.KmsClient'):
            args = default_args()
            action = EncryptAction(args)
            action._config = Mock()
            action.action()

            args.store = True

            action = EncryptAction(args)