Skip to content

Comments

unify http request and base http#209

Merged
christinadomanskaya merged 8 commits intomainfrom
feature/unify_http_request_and_base_http
Apr 12, 2022
Merged

unify http request and base http#209
christinadomanskaya merged 8 commits intomainfrom
feature/unify_http_request_and_base_http

Conversation

@intsynko
Copy link
Collaborator

Объединил HTTPRequestAction и BaseHTTPRequestAction на основе HTTPRequestAction.

Это нужно для того чтобы не изменять структуру ответа и оставить её единой для всех экшенов (BaseHTTPRequestAction возвращал ответ, а в сигнатуре метода run у всех экешенов: Optional[List[Command]]).

self.behavior = items.get("behavior")

def preprocess(self, user, text_processing, params):
behavior_description = user.descriptions["behaviors"][self.behavior]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По-моему, если не указать в items behavior, то эта строчка уронит апп.

Возможный фикс:

Suggested change
behavior_description = user.descriptions["behaviors"][self.behavior]
behavior_description = user.descriptions["behaviors"].get(self.behavior)

def preprocess(self, user, text_processing, params):
behavior_description = user.descriptions["behaviors"][self.behavior]
self.http_action.method_params.setdefault("timeout", behavior_description.timeout(user))
self.method_params.setdefault("timeout", behavior_description.timeout(user))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если self.behavior не указан? Вызов атрибута timeout от None?

Copy link
Collaborator

@SyrexMinus SyrexMinus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё ок, но нужен тест на случай, когда не указан behavior.

self.method_params.setdefault("timeout", behavior_description.timeout(user))
behavior_description = user.descriptions["behaviors"].get(self.behavior)
if behavior_description:
self.method_params.setdefault("timeout", behavior_description.timeout(user))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Без тайм-аута будет нехорошо. Надо поставить хоть какой-то.

@christinadomanskaya christinadomanskaya merged commit c0792ec into main Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants