# Path: lamvery/actions/encrypt_file.py
# class EncryptFileAction(BaseAction):
# 
#     def __init__(self, args):
#         super(EncryptFileAction, self).__init__(args)
#         self._file = args.name
#         self._path = args.path
#         self._store = args.store
# 
#     def action(self):
#         cipher_text = self.get_kms_client().encrypt(
#             self._config.get_secret().get('key_id'), open(self._path, 'r').read())
# 
#         if self._store:
#             self._config.store_secret_file(self._file, cipher_text)
#         else:
#             print(cipher_text)


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




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.path = 'requirements.txt'
    args.name = 'bar.txt'
    args.store = False
    return args


class EncryptActionTestCase(TestCase):

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

            args.store = True

# Path: lamvery/actions/encrypt_file.py
# class EncryptFileAction(BaseAction):
# 
#     def __init__(self, args):
#         super(EncryptFileAction, self).__init__(args)
#         self._file = args.name
#         self._path = args.path
#         self._store = args.store
# 
#     def action(self):
#         cipher_text = self.get_kms_client().encrypt(
#             self._config.get_secret().get('key_id'), open(self._path, 'r').read())
# 
#         if self._store:
#             self._config.store_secret_file(self._file, cipher_text)
#         else:
#             print(cipher_text)


# Path: tests/lamvery/actions/encrypt_file_test.py
from unittest import TestCase
from mock import Mock, patch
from lamvery.actions.encrypt_file import EncryptFileAction

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




def default_args():
    args = Mock()
    args.conf_file = '.lamvery.yml'
    args.path = 'requirements.txt'
    args.name = 'bar.txt'
    args.store = False
    return args


class EncryptActionTestCase(TestCase):

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

            args.store = True

            action = EncryptFileAction(args)