def execute_tests()

in codes/lambda/api-testing-tester/src/http_request_tester.py [0:0]


    def execute_tests(self, test_list):
        for data in test_list:
            body = data['request']
            type = '{}/{}'.format(self.test_name, data['type'])
            resource = '/{}/{}'.format(self.project_stage, data['resource'])
            
            status, response = self.request_post(type, self.endpoint, resource, None, None, body)
            if response is not None:
                expected_keys = data['response'].keys()
                result_keys = response.keys()
                success = True
                for expected_key in expected_keys:
                    if expected_key in result_keys:
                        if not response[expected_key] == data['response'][expected_key]:
                            success = False
                            logger.error('start_request_with_timer: response compare - {} != {}'.format(response[expected_key], data['response'][expected_key]))
                            break    
                    else:
                        success = False
                        logger.error('start_request_with_timer: response empty')
                        break
                
                if success == True:
                    self.put_metric(MetricType.TestSuccess, 1.0, self.project_name, self.project_stage, type)
                else:
                    self.put_metric(MetricType.TestFail, 1.0, self.project_name, self.project_stage, type)
            time.sleep(data['interval'])