Skip to content

Commit

Permalink
fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmadurga committed Mar 30, 2016
1 parent 7032c0f commit f7cfe09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion microbot/serializers.py
Expand Up @@ -146,7 +146,7 @@ def create(self, validated_data):
enabled=validated_data['enabled'],
request=request,
target_state=state,
priority=validated_data.get('priority',0))
priority=validated_data.get('priority', 0))

self._create_params(validated_data['request']['url_parameters'], UrlParam, request)
self._create_params(validated_data['request']['header_parameters'], HeaderParam, request)
Expand Down
21 changes: 11 additions & 10 deletions tests/test_api.py
Expand Up @@ -323,7 +323,8 @@ def _handler_header_param_list_url(self, bot_pk=None, handler_pk=None):
handler_pk = self.handler.pk
return '%s/bots/%s/handlers/%s/headerparams/' % (self.api, bot_pk, handler_pk)

def assertHandler(self, name, pattern, response_text_template, response_keyboard_template, enabled, priority, target_state_name, source_states_names, handler=None):
def assertHandler(self, name, pattern, response_text_template, response_keyboard_template, enabled, priority, target_state_name,
source_states_names, handler=None):
if not handler:
handler = self.handler
self.assertEqual(handler.name, name)
Expand Down Expand Up @@ -387,7 +388,7 @@ def test_post_handlers_with_target_state_ok(self):
self.handler.target_state = self.state
self.handler.save()
data = {'name': self.handler.name, 'pattern': self.handler.pattern,
'target_state': {'name': self.state.name}, 'priority' : self.handler.priority,
'target_state': {'name': self.state.name}, 'priority': self.handler.priority,
'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template},
'enabled': False, 'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
Expand All @@ -405,7 +406,7 @@ def test_post_handlers_with_target_state_ok(self):

def test_post_handlers_with_target_state_new_state_ok(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern,
'target_state': {'name': 'new_state'}, 'priority' : self.handler.priority,
'target_state': {'name': 'new_state'}, 'priority': self.handler.priority,
'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template},
'enabled': False, 'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
Expand All @@ -422,7 +423,7 @@ def test_post_handlers_with_target_state_new_state_ok(self):

def test_post_handlers_not_auth(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': self.handler.request}
self._test_post_list_not_auth(self._handler_list_url(), data)

Expand Down Expand Up @@ -452,7 +453,7 @@ def test_get_handler_not_found(self):

def test_put_handler_ok(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'url_parameters': [{'key': self.handler.request.url_parameters.all()[0].key,
'value_template': 'new_url_param_value'}],
Expand All @@ -467,7 +468,7 @@ def test_put_handler_ok(self):

def test_put_handler_with_target_new_state_ok(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'url_parameters': [{'key': self.handler.request.url_parameters.all()[0].key,
'value_template': 'new_url_param_value'}],
Expand All @@ -487,7 +488,7 @@ def test_put_handler_with_target_state_ok(self):
self.handler.target_state = self.state
self.handler.save()
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : 2,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': 2,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'url_parameters': [{'key': self.handler.request.url_parameters.all()[0].key,
'value_template': 'new_url_param_value'}],
Expand All @@ -505,23 +506,23 @@ def test_put_handler_with_target_state_ok(self):

def test_put_handler_from_other_bot(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'data': self.handler.request.data}
}
self._test_put_detail_from_other_bot(self._handler_detail_url, data, HandlerDetail, self.handler.pk)

def test_put_handler_not_auth(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'data': self.handler.request.data}
}
self._test_put_detail_not_auth(self._handler_detail_url(), data, HandlerDetail, self.bot.pk, self.handler.pk)

def test_put_handler_not_found(self):
data = {'name': self.handler.name, 'pattern': self.handler.pattern, 'response': {'text_template': self.handler.response.text_template,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority' : self.handler.priority,
'keyboard_template': self.handler.response.keyboard_template}, 'enabled': False, 'priority': self.handler.priority,
'request': {'url_template': self.handler.request.url_template, 'method': self.handler.request.method,
'data': self.handler.request.data}
}
Expand Down

0 comments on commit f7cfe09

Please sign in to comment.