def test_validate_http_action_empty_params_list_3(self): test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "params_list": [{ "key": 'location', "parameter_type": 'value', "value": 'Mumbai' }, { "key": 'username', "parameter_type": 'slot', "value": '' }], "request_method": "GET", "response": "${RESPONSE}" }] } TrainingDataValidator.validate_http_actions(test_dict) assert test_dict['http_actions'][0]['params_list'][1][ 'value'] == 'username'
def test_validate_http_action_empty_params_list_5(self): test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "request_method": "GET", "response": "${RESPONSE}" }] } assert not TrainingDataValidator.validate_http_actions(test_dict)
def test_validate_http_action_error_missing_field(self): test_dict = { 'http_actions': [{ 'http_url': "http://www.alphabet.com", "response": 'asdf', "request_method": 'POST' }] } errors = TrainingDataValidator.validate_http_actions(test_dict) assert 'Required http action fields not found' in errors
def test_validate_http_action_params_list_4(self): test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "params_list": [{ "key": 'location', "parameter_type": 'value', "value": '' }], "request_method": "GET", "response": "${RESPONSE}" }] } assert not TrainingDataValidator.validate_http_actions(test_dict) test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "params_list": [{ "key": 'location', "parameter_type": 'value', "value": None }], "request_method": "GET", "response": "${RESPONSE}" }] } assert not TrainingDataValidator.validate_http_actions(test_dict)
def test_validate_http_action_error_duplicate(self): test_dict = { 'http_actions': [{ 'action_name': "act2", 'http_url': "http://www.alphabet.com", "response": 'asdf', "request_method": 'POST' }, { 'action_name': "act2", 'http_url': "http://www.alphabet.com", "response": 'asdf', "request_method": 'POST' }] } errors = TrainingDataValidator.validate_http_actions(test_dict) assert 'Duplicate http action found: act2' in errors
def test_validate_http_action_empty_params_list_2(self): test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "params_list": [{ "key": 'location', "parameter_type": '', "value": '' }], "request_method": "GET", "response": "${RESPONSE}" }] } errors = TrainingDataValidator.validate_http_actions(test_dict) assert 'Invalid params_list for http action: rain_today' in errors
def test_validate_http_action_invalid_request_method(self): test_dict = { "http_actions": [{ "action_name": "rain_today", "http_url": "http://f2724.kairon.io/", "params_list": [{ "key": 'location', "parameter_type": 'slot', "value": 'slot' }], "request_method": "OPTIONS", "response": "${RESPONSE}" }] } errors = TrainingDataValidator.validate_http_actions(test_dict) assert 'Invalid request method: rain_today' in errors
def test_validate_http_action_empty_content(self): test_dict = {'http_actions': []} assert not TrainingDataValidator.validate_http_actions(test_dict) assert not TrainingDataValidator.validate_http_actions({})