How to use history_show method in stestr

Best Python code snippet using stestr_python

history.py

Source:history.py Github

copy

Full Screen

...122 args.no_subunit_trace123 color = args.color124 suppress_attachments = args.suppress_attachments125 all_attachments = args.all_attachments126 return history_show(127 args.run_id,128 repo_url=self.app_args.repo_url,129 subunit_out=args.subunit,130 pretty_out=pretty_out, color=color,131 suppress_attachments=suppress_attachments,132 all_attachments=all_attachments,133 show_binary_attachments=args.show_binary_attachments)134class HistoryRemove(command.Command):135 """Remove a run from the history"""136 def get_parser(self, prog_name):137 remove_parser = super().get_parser(prog_name)138 remove_parser.add_argument('run_id',139 help='The run id to remove from the '140 'repository. Also the string "all" '141 'can be used to remove all runs in '142 'the history')143 return remove_parser144 def take_action(self, parsed_args):145 args = parsed_args146 history_remove(args.run_id,147 repo_url=self.app_args.repo_url)148start_times = None149stop_times = None150def _get_run_details(stream_file, stdout):151 stream = subunit.ByteStreamToStreamResult(stream_file,152 non_subunit_name='stdout')153 global start_times154 global stop_times155 start_times = []156 stop_times = []157 def collect_data(stream, test):158 global start_times159 global stop_times160 start_times.append(test['timestamps'][0])161 stop_times.append(test['timestamps'][1])162 outcomes = testtools.StreamToDict(functools.partial(collect_data, stdout))163 summary = testtools.StreamSummary()164 result = testtools.CopyStreamResult([outcomes, summary])165 result = testtools.StreamResultRouter(result)166 cat = subunit.test_results.CatFiles(stdout)167 result.add_rule(cat, 'test_id', test_id=None)168 result.startTestRun()169 try:170 stream.run(result)171 finally:172 result.stopTestRun()173 successful = results.wasSuccessful(summary)174 if start_times and stop_times:175 start_time = min(start_times)176 stop_time = max(stop_times)177 run_time = subunit_trace.get_duration([start_time, stop_time])178 else:179 run_time = '---'180 successful = '---'181 start_time = '---'182 return {'passed': successful, 'runtime': run_time, 'start': start_time}183def history_list(repo_url=None, show_metadata=False,184 stdout=sys.stdout):185 """Show a list of runs in a repository186 Note this function depends on the cwd for the repository if `repo_url` is187 not specified it will use the repository located at CWD/.stestr188 :param str repo_url: The url of the repository to use.189 :param bool show_metadata: If set to ``True`` a column with any metadata190 for a run will be included in the output.191 :param file stdout: The output file to write all output to. By default192 this is sys.stdout193 :return return_code: The exit code for the command. 0 for success and > 0194 for failures.195 :rtype: int196 """197 field_names = ()198 if show_metadata:199 field_names = ('Run ID', 'Passed', 'Runtime', 'Date', 'Metadata')200 else:201 field_names = ('Run ID', 'Passed', 'Runtime', 'Date')202 try:203 repo = util.get_repo_open(repo_url=repo_url)204 except abstract.RepositoryNotFound as e:205 stdout.write(str(e) + '\n')206 return 1207 try:208 run_ids = repo.get_run_ids()209 except KeyError as e:210 stdout.write(str(e) + '\n')211 return 1212 rows = []213 for run_id in run_ids:214 run = repo.get_test_run(run_id)215 stream = run.get_subunit_stream()216 data = _get_run_details(stream, stdout)217 if show_metadata:218 rows.append((run_id, data['passed'], data['runtime'],219 data['start'], run.get_metadata()))220 else:221 rows.append((run_id, data['passed'], data['runtime'],222 data['start']))223 return (field_names, rows)224def history_show(run_id, repo_url=None, subunit_out=False,225 pretty_out=True, color=False, stdout=sys.stdout,226 suppress_attachments=False, all_attachments=False,227 show_binary_attachments=False):228 """Show a run loaded into a repository229 This function will print the results from the last run in the repository230 to STDOUT. It can optionally print the subunit stream for the last run231 to STDOUT if the ``subunit`` option is set to true.232 Note this function depends on the cwd for the repository if `repo_url` is233 not specified it will use the repository located at CWD/.stestr234 :param str run_id: The run id to show235 :param str repo_url: The url of the repository to use.236 :param bool subunit_out: Show output as a subunit stream.237 :param pretty_out: Use the subunit-trace output filter.238 :param color: Enable colorized output with the subunit-trace output filter....

Full Screen

Full Screen

history_show.py

Source:history_show.py Github

copy

Full Screen

1#!/usr/bin/env python32# Copyright 2019 Broadcom. All rights reserved.3# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.4#5# Licensed under the Apache License, Version 2.0 (the "License");6# you may not use this file except in compliance with the License.7# You may also obtain a copy of the License at8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15# history_show.py(pyGen v1.0.0)16"""17:mod:`history_show` - PyFOS util to display history log records of all \18the FRU's.19*********************************************************************************20The :mod:`history_show` util displays history log records of all the FRU's.21This module is a stand-alone script that can be used to display history22log records of all the fru's.23* Input:24| Infrastructure Options:25 | -i,--ipaddr=IPADDR The IP address of the FOS switch.26 | -L,--login=LOGIN The login name.27 | -P,--password=PASSWORD The password.28 | -f,--vfid=VFID The VFID to which the request is \29 directed [OPTIONAL].30 | -s,--secured=MODE The HTTPS mode "self" or "CA" [OPTIONAL].31 | -v,--verbose Verbose mode [OPTIONAL].32* Output:33 * Python dictionary content with RESTCONF response data.34"""35import sys36from pyfos import pyfos_auth37from pyfos import pyfos_util38from pyfos.pyfos_brocade_fru import history_log39from pyfos.utils import brcd_util40def show_history_details(session):41 history_obj = history_log()42 result = history_obj.get(session)43 return result44def main(argv):45 # Print arguments46 # print(sys.argv[1:])47 filters = []48 inputs = brcd_util.parse(argv, history_log, filters)49 session = brcd_util.getsession(inputs)50 result = show_history_details(inputs['session'])51 pyfos_util.response_print(result)52 pyfos_auth.logout(session)53if __name__ == "__main__":...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import path2from django.contrib.auth import views as auth_views3from . import views4from django.conf.urls.static import static5from django.conf import settings6urlpatterns = [7 path('', views.post_list, name='post_list'),8 path('post/<int:pk>/', views.post_detail, name='post_detail'),9 path('post/new/', views.post_new, name='post_new'),10 path('post/<int:pk>/edit/', views.post_edit, name='post_edit'),11 path('post/<int:pk>/delete/', views.post_delete, name='post_delete'),12 path('accounts/login/', auth_views.LoginView.as_view(redirect_authenticated_user=True), name='login'),13 path('accounts/<int:pk>/', views.get_user_profile, name='user_profile'),14 path('accounts/<int:pk>/edit/', views.edit_user_profile, name='edit_user_profile'),15 path('theory/', views.theory, name='theory'),16 path('about_program/', views.about_program, name='about_program'),17 path('calculation', views.calculation_new, name='calculation_new'),18 path('calculation/<int:pk>/detail', views.calculation_detail, name='calculation_detail'),19 path('calculation/<int:pk>/delete', views.calculation_delete, name='calculation_delete'),20 path('history/', views.history_show, name='history_show'),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stestr automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful