# Path: efopen/ef_site_config.py
# class EFSiteConfig(object):
#   def __init__(self):
#   def load(self):
#   def load_from_ssm(self):
#   def load_from_local_file(self):


import os
import unittest
from mock import MagicMock, Mock, patch, mock_open
from efopen import ef_site_config
                      'load_from_local_file') as mock_file_load:

        mock_file_load.return_value = {"Configuration": "file"}
        test_config = ef_site_config.EFSiteConfig().load()
        # whereami return value doesn't matter
        whereami.assert_called_once()
        mock_file_load.assert_called_once()
        self.assertDictEqual(test_config, mock_file_load.return_value)

  def test_site_config_load_from_ssm_on_ec2(self):
    with patch('efopen.ef_utils.whereami') as whereami,\
         patch.object(ef_site_config.EFSiteConfig,
                      'load_from_ssm') as mock_ssm_load:

      mock_ssm_load.return_value = {"Configuration": "file"}
      whereami.return_value = 'ec2'
      test_config = ef_site_config.EFSiteConfig().load()
      whereami.assert_called_once()
      mock_ssm_load.assert_called_once()
      self.assertDictEqual(test_config, mock_ssm_load.return_value)

  def test_load_from_ssm(self):
    with patch('boto3.client') as boto3_client_func:
      config_value = 'Hello world'
      ssm_client_mock = Mock(name='ssm_client_mock')
      boto3_client_func.return_value = ssm_client_mock
      ssm_parameter =  {'Parameter': {'Value': config_value}}
      get_parameter_mock = ssm_client_mock.get_parameter
      get_parameter_mock.return_value = ssm_parameter


# Path: efopen/ef_site_config.py
# class EFSiteConfig(object):
#   def __init__(self):
#   def load(self):
#   def load_from_ssm(self):
#   def load_from_local_file(self):


# Path: tests/unit_tests/test_ef_site_config.py
import os
import unittest
from mock import MagicMock, Mock, patch, mock_open
from efopen import ef_site_config

                      'load_from_local_file') as mock_file_load:

        mock_file_load.return_value = {"Configuration": "file"}
        test_config = ef_site_config.EFSiteConfig().load()
        # whereami return value doesn't matter
        whereami.assert_called_once()
        mock_file_load.assert_called_once()
        self.assertDictEqual(test_config, mock_file_load.return_value)

  def test_site_config_load_from_ssm_on_ec2(self):
    with patch('efopen.ef_utils.whereami') as whereami,\
         patch.object(ef_site_config.EFSiteConfig,
                      'load_from_ssm') as mock_ssm_load:

      mock_ssm_load.return_value = {"Configuration": "file"}
      whereami.return_value = 'ec2'
      test_config = ef_site_config.EFSiteConfig().load()
      whereami.assert_called_once()
      mock_ssm_load.assert_called_once()
      self.assertDictEqual(test_config, mock_ssm_load.return_value)

  def test_load_from_ssm(self):
    with patch('boto3.client') as boto3_client_func:
      config_value = 'Hello world'
      ssm_client_mock = Mock(name='ssm_client_mock')
      boto3_client_func.return_value = ssm_client_mock
      ssm_parameter =  {'Parameter': {'Value': config_value}}
      get_parameter_mock = ssm_client_mock.get_parameter
      get_parameter_mock.return_value = ssm_parameter


      test_config = ef_site_config.EFSiteConfig().load_from_ssm()