def setup(self): """Setup before each method""" self.ssm_patcher = patch.object(AppConfig, 'SSM_CLIENT', MockSSMClient()) self.mock_ssm = self.ssm_patcher.start() self._config = AppConfig.load_config( get_mock_context(), {'invocation_type': 'successive_invoke'})
def test_parse_context(self): """AppIntegrationConfig - Parse Context""" mock_context = get_mock_context() result = AppConfig._parse_context(mock_context) assert_equal(AppConfig.remaining_ms, mock_context.get_remaining_time_in_millis) assert_equal(AppConfig.remaining_ms(), 100) assert_equal(result['function_name'], FUNCTION_NAME)
def test_handler_success(gather_mock, config_mock, failure_mock): """App Integration - Test Handler, Success""" base_config = get_valid_config_dict('duo_auth') config_mock.return_value = AppConfig(base_config) gather_mock.return_value = None handler(None, get_mock_context()) failure_mock.assert_not_called()
def test_handler_bad_type(config_mock, failure_mock): """App Integration - Test Handler, Bad Service Type""" base_config = get_valid_config_dict('duo_auth') base_config.update({'type': 'bad_type', 'current_state': 'running'}) config_mock.return_value = AppConfig(base_config) handler(None, get_mock_context()) failure_mock.assert_called()
def test_determine_last_timestamp_box(self, time_mock): """AppIntegrationConfig - Determine Last Timestamp, Box""" with patch.object(AppConfig, 'SSM_CLIENT', MockSSMClient(app_type='box_admin_events')): self._config = AppConfig.load_config(get_mock_context(), None) # Reset the last timestamp to None self._config.last_timestamp = None # Use a mocked current time time_mock.return_value = 1234567890 assert_equal(self._config._determine_last_time(), '2009-02-13T22:31:30-00:00')
def test_load_config_new_client(self, boto_mock): """AppIntegrationConfig - Load config, new SSM client""" boto_mock.return_value = MockSSMClient(app_type='onelogin_events') with patch.object(AppConfig, 'SSM_CLIENT', None): self._config = AppConfig.load_config(get_mock_context(), None) boto_mock.assert_called()
def test_is_successive_invocation(self): """AppIntegrationConfig - Is Successive Invocation""" assert_true(self._config.is_successive_invocation) self._config = AppConfig.load_config(get_mock_context(), None) assert_false(self._config.is_successive_invocation)
def setup(self): """Setup before each method""" self._config = AppConfig.load_config(get_mock_context())
def test_handler(): """App Integration - Test Handler""" handler(None, get_mock_context())
def setup(self): """Setup before each method""" self.ssm_patcher = patch.object(AppConfig, 'SSM_CLIENT', MockSSMClient()) self.mock_ssm = self.ssm_patcher.start() self._config = AppConfig.load_config(get_mock_context())