示例#1
0
 def test_invalid_type(self):
     with open(r'tests/events/invalid_type.json') as file:
         event = json.load(file)
     self.event = event
     result = app.handler(self.event, None)
     self.assertEqual('failure', result['status'])
     self.assertEqual(app.MISSING_TYPE_ERROR_MESSAGE,
                      result['errorMessage'])
示例#2
0
 def test_name_missing(self):
     with open(r'tests/events/name_param_missing.json') as file:
         event = json.load(file)
     self.event = event
     result = app.handler(self.event, None)
     self.assertEqual('failure', result['status'])
     self.assertEqual(app.MISSING_NAME_ERROR_MESSAGE,
                      result['errorMessage'])
示例#3
0
 def test_invalid_name(self):
     ssm = boto3.client('ssm')
     with Stubber(ssm) as stubber:
         stubber.add_client_error(method='get_parameter',
                                  service_error_code='ParameterNotFound')
         app.get_ssm_client = MagicMock(return_value=ssm)
         with open(r'tests/events/invalid_name.json') as file:
             self.event = json.load(file)
         result = app.handler(self.event, None)
         print(result)
         self.assertEqual('failure', result['status'])
         param_not_found_error = 'An error occurred (ParameterNotFound) when calling the GetParameter operation: '
         self.assertEqual(param_not_found_error, result['errorMessage'])
示例#4
0
    def test_string(self):
        ssm = boto3.client('ssm')
        with Stubber(ssm) as stubber:
            expected_value = 'first test string'
            response = self.create_mock_response('String', expected_value)
            stubber.add_response('get_parameter', response)
            app.get_ssm_client = MagicMock(return_value=ssm)

            with open(r'tests/events/string.json') as file:
                event = json.load(file)
            self.event = event
            result = app.handler(self.event, None)
            print(result)
            fragment = result['fragment']
            print(fragment)

            self.assertEqual(fragment, expected_value)