Skip to content

Support planned_first and failed_first for get_tests_to_resume #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions backslash/contrib/slash_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,25 @@ def is_session_exist(self, session_id):

@handle_exceptions
@slash.plugins.registers_on(None)
def get_tests_to_resume(self, session_id, get_successful=False):
params = {'session_id':session_id, 'show_successful':get_successful, 'show_planned':'true'}
def get_tests_to_resume(self, session_id, get_successful=False, planned_first=False, failed_first=False):
max_retries = 3
for i in range(max_retries):
try:
return reversed(LazyQuery(self.client, '/rest/tests', query_params=params).all())
if not planned_first and not failed_first:
params = {'session_id': session_id, 'show_successful': get_successful, 'show_planned':'true'}
return reversed(LazyQuery(self.client, '/rest/tests', query_params=params).all())
planned_filters = ['show_planned', 'show_skipped']
failed_filters = ['show_unsuccessful', 'show_abandoned']
wanted_first = failed_filters if failed_first else planned_filters

first_params = {kwarg_name: (kwarg_name in wanted_first) for kwarg_name in failed_filters + planned_filters}
opposite_params = {k: not v for k, v in first_params.items()}
first_params.update({'session_id':session_id, 'show_successful': False})
opposite_params.update({'session_id':session_id, 'show_successful': get_successful})
first = LazyQuery(self.client, '/rest/tests', query_params=first_params).all()
others = LazyQuery(self.client, '/rest/tests', query_params=opposite_params).all()
others.extend(first)
return reversed(others)
except HTTPError:
if i == max_retries-1:
raise
Expand Down