How to use show_snapshot method in tempest

Best Python code snippet using tempest_python

read.py

Source:read.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# This file is part of IRIS: Infrastructure and Release Information System3#4# Copyright (C) 2013 Intel Corporation5#6# IRIS is free software; you can redistribute it and/or7# modify it under the terms of the GNU General Public License8# version 2.0 as published by the Free Software Foundation.9"""10This is the read view file for the iris-submissions application.11Views for listing single and multiple item info is contained here.12"""13# pylint: disable=E1101,C0111,W0622,C030114from django.shortcuts import render, get_object_or_40415from django.contrib.auth.decorators import login_required16from django.db.models import Q17from django.http import (18 Http404, HttpResponseRedirect, HttpResponseBadRequest, HttpResponse)19from django.core.urlresolvers import reverse20from django.core.paginator import Paginator21from django.core.exceptions import ValidationError22from iris.core.models import (23 Submission, BuildGroup, SubmissionGroup, Snapshot, Product, DISPLAY_STATUS)24def index(request):25 """26 Index page of Submissions app.27 If a user logged-in, redirect to "my submissions" page,28 otherwise redirect to "opened submissions" page.29 """30 if request.user.is_authenticated():31 url = reverse('my_submissions')32 else:33 url = reverse('opened_submissions')34 return HttpResponseRedirect(url)35def get_submissions(**query):36 return [sub for sub in Submission.objects.select_related(37 'owner', 'gittree').filter(**query).prefetch_related(38 'submissionbuild_set__product',39 'submissionbuild_set__group',40 'submissionbuild_set__group__snapshot',41 )]42def opened(request):43 """44 All opened submissions45 """46 subs = [sub for sub in get_submissions() if sub.opened]47 return render(request, 'submissions/summary.html', {48 'title': 'All open submissions',49 'results': SubmissionGroup.group(subs, DISPLAY_STATUS['OPENED']),50 'keyword': 'status:%s' % DISPLAY_STATUS['OPENED'],51 })52def accepted(request):53 """54 All accepted submissions55 """56 subs = [sub for sub in get_submissions() if sub.accepted]57 return render(request, 'submissions/summary.html', {58 'title': 'All accepted submissions',59 'results': SubmissionGroup.group(subs, DISPLAY_STATUS['ACCEPTED']),60 'keyword': 'status:%s' % DISPLAY_STATUS['ACCEPTED'],61 'show_snapshot': True,62 })63def rejected(request):64 """65 All rejected submissions66 """67 subs = [sub for sub in get_submissions() if sub.rejected]68 return render(request, 'submissions/summary.html', {69 'title': 'All rejected submissions',70 'results': SubmissionGroup.group(subs, DISPLAY_STATUS['REJECTED']),71 'keyword': 'status:%s' % DISPLAY_STATUS['REJECTED'],72 })73@login_required74def mine(request):75 """76 All my (the logged-in user) opened submissions77 TODO: add menu as all did, show opened, rejected, accepted78 """79 subs = [sub for sub in get_submissions(owner=request.user) if sub.opened]80 return render(request, 'submissions/summary.html', {81 'title': 'My submissions',82 'results': SubmissionGroup.group(subs, DISPLAY_STATUS['OPENED']),83 'keyword': 'status:%s owner:%s' % (DISPLAY_STATUS['OPENED'],84 request.user.email)85 })86def parse_query_string(query_string):87 """88 validate keyworkd used for search submission89 support keyword format:90 1. key:value key:value(more key:value separated with space) value91 support keyes: status, name, owner, gittree92 2. key:value key:value(more key:value separated with space)93 3. value94 4. only value means the value can be name, owner, gittree or commit95 5. Only one value with no key is supported96 """97 kw = {}98 for item in query_string.split():99 if ':' not in item:100 if kw.get('query'):101 return102 kw['query'] = item103 continue104 key, val = item.split(':', 1)105 key = key.lower()106 if key not in ('status', 'name', 'owner', 'gittree'):107 return108 if key == 'status' and val not in DISPLAY_STATUS.values():109 return110 kw[key] = val111 return kw112def validate_search(request):113 """ Ajax view for validte keyword before search """114 if request.GET.get('kw') and parse_query_string(request.GET.get('kw')):115 return HttpResponse('ok')116 return HttpResponseBadRequest('error')117def make_query_conditions(kw):118 fields = {119 'name': ['name__contains'],120 'owner': [121 'owner__email__startswith',122 'owner__first_name__contains',123 'owner__last_name__contains',124 ],125 'gittree': ['gittree__gitpath__contains'],126 'query': [127 'name__contains',128 'owner__email__startswith',129 'owner__first_name__contains',130 'owner__last_name__contains',131 'commit__startswith',132 'gittree__gitpath__contains',133 ],134 }135 def _and(*args):136 return reduce(lambda i, j: i & j, *args)137 def _or(*args):138 return reduce(lambda i, j: i | j, *args)139 return _and([140 _or([Q(**{field: val}) for field in fields[key]])141 for key, val in kw.items()])142def search(request):143 """Search submissions by keyword """144 querystring = request.GET.get('kw')145 if not querystring:146 return HttpResponseBadRequest('error')147 kw = parse_query_string(querystring)148 st = kw.pop('status', None) if kw else None149 subs = Submission.objects.select_related('owner', 'gittree', 'product')150 if kw:151 query = make_query_conditions(kw)152 subs = subs.filter(query)153 else:154 subs = subs.all()155 show_snapshot = False156 if st:157 if st == DISPLAY_STATUS['OPENED']:158 subs = {sub for sub in subs if sub.opened}159 if st == DISPLAY_STATUS['REJECTED']:160 subs = {sub for sub in subs if sub.rejected}161 if st == DISPLAY_STATUS['ACCEPTED']:162 subs = {sub for sub in subs if sub.accepted}163 show_snapshot = True164 return render(165 request,166 'submissions/summary.html',167 {'title': 'Search result for "%s"' % querystring,168 'results': SubmissionGroup.group(subs, st),169 'keyword': querystring,170 'show_snapshot': show_snapshot171 })172def detail(request, tag):173 """174 Detail info about a submission group identified by certain tag175 """176 groups = SubmissionGroup.group(177 Submission.objects.filter(name=tag.rstrip('/')))178 if not groups:179 raise Http404180 assert len(groups) == 1 # because it's group by tag181 sgroup = groups[0]182 bgroups = submission_group_to_build_groups(sgroup)183 return render(184 request,185 'submissions/detail.html',186 {'sgroup': sgroup,187 'bgroups': bgroups,188 })189def submission_group_to_build_groups(sgroup):190 """191 Find build groups by submission group (tag)192 """193 return {sbuild.group194 for submission in sgroup.subs195 for sbuild in submission.submissionbuild_set.all()}196def snapshot_by_product(request, product_id, offset=0, limit=10):197 """198 if change limit, please also update the value in template:199 iris/submissions/templates/submissions/read/multiple/snapshots.html200 """201 pro = Product.objects.get(pk=product_id)202 all_snapshots = Snapshot.snapshots_with_same_product(pro)203 offset = int(offset)204 limit = int(limit)205 end = offset + limit206 more_data = True207 if end >= len(all_snapshots):208 more_data = False209 snapshots = all_snapshots[offset:end]210 for snapshot in snapshots:211 groups = SubmissionGroup.group(snapshot.submissions)212 snapshot.groups = sorted(groups,213 key=lambda group: group.name,214 reverse=True)215 if request.is_ajax():216 response = render(request, 'submissions/read/multiple/snapshot_submissions.html', {217 'snapshots': snapshots,218 'product': pro,219 })220 response['X-No-More'] = more_data221 return response222 else:223 return render(request, 'submissions/read/multiple/snapshots.html', {224 'snapshots': snapshots,225 'product': pro,226 'more_data': more_data,227 })228def snapshot(request, pkid):229 snapshot = get_object_or_404(Snapshot, id=pkid)230 groups = SubmissionGroup.group(snapshot.submissions)231 # get snapshots with the same product232 snapshots = list(Snapshot.snapshots_with_same_product(snapshot.product))233 st_len = len(snapshots)234 first_item = False235 last_item = False236 pre_st = None237 next_st = None238 current_index = snapshots.index(snapshot)239 if current_index == 0:240 first_item = True241 else:242 pre_st = snapshots[current_index-1]243 if current_index == (st_len -1):244 last_item = True245 else:246 next_st = snapshots[current_index+1]247 return render(request, 'submissions/read/single/snapshot.html', {248 'snapshot': snapshot,249 'groups': groups,250 'pre_st': pre_st,251 'next_st': next_st,252 'first_item': first_item,253 'last_item': last_item,...

Full Screen

Full Screen

progress.py

Source:progress.py Github

copy

Full Screen

1from enum import Enum2from PyQt5 import QtWidgets, QtCore3from ..job_queue import Job, JobState4class ProgressState(Enum):5 PAUSED = "Continue"6 RUNNING = "Pause"7class ProgressWidget(QtWidgets.QWidget):8 def __init__(self, job_signal, tabWidget, parent=None):9 super().__init__(parent=parent)10 self.tabWidget = tabWidget11 job_signal.connect(self.set_job)12 self.state = ProgressState.RUNNING13 self.job = None14 self.show_snapshot = False15 self.MAX_ROWS = 2016 self.layout = QtWidgets.QVBoxLayout()17 self.setLayout(self.layout)18 self.create_state_widget()19 self.create_snapshot()20 # self.create_dump()21 # self.create_headings()22 # self.create_log()23 def create_state_widget(self):24 stateWidget = QtWidgets.QWidget()25 stateWidget.layout = QtWidgets.QHBoxLayout()26 stateWidget.layout.setContentsMargins(11, 0, 11, 0)27 stateWidget.setLayout(stateWidget.layout)28 self.stateLabel = QtWidgets.QLabel("State: Stopped")29 stateWidget.layout.addWidget(self.stateLabel)30 self.rowCount = QtWidgets.QLabel("Rows: " + str(0))31 stateWidget.layout.addWidget(self.rowCount)32 stateWidget.layout.addStretch(1)33 self.layout.addWidget(stateWidget)34 def create_snapshot(self):35 self.snapshotCheckBox = QtWidgets.QCheckBox("Show snapshot")36 self.snapshotCheckBox.toggled.connect(self.toggle_snapshot)37 self.layout.addWidget(self.snapshotCheckBox)38 self.snapshot = QtWidgets.QTableWidget()39 self.snapshot.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed)40 self.snapshot.horizontalHeader().setSectionResizeMode(41 QtWidgets.QHeaderView.Interactive42 )43 self.snapshot.horizontalHeader().setCascadingSectionResizes(True)44 self.layout.addWidget(self.snapshot)45 def update_snapshot(self):46 state = self.job.state47 self.stateLabel.setText("State: " + str(state.value))48 if self.tabWidget.currentIndex() != 4:49 return50 data = self.job.data.data51 keys = list(self.job.data.keys)52 # Otherwise it changes during update53 rows = self.job.data.count54 self.rowCount.setText("Rows: " + str(rows))55 # Reduce update rate56 if (57 not (rows % self.MAX_ROWS and state) == JobState.RUNNING58 or not self.show_snapshot59 ):60 return61 if rows > self.MAX_ROWS:62 self.snapshot.setRowCount(self.MAX_ROWS)63 self.snapshot.verticalHeader().setSectionResizeMode(64 QtWidgets.QHeaderView.Stretch65 )66 self.snapshot.setVerticalHeaderLabels(67 (str(val) for val in range(rows - self.MAX_ROWS + 1, rows + 1))68 )69 else:70 self.snapshot.setRowCount(rows)71 self.snapshot.setColumnCount(len(keys))72 self.snapshot.setHorizontalHeaderLabels(keys)73 for row_c, datum in enumerate(data[-25:]):74 for col_c, heading in enumerate(keys):75 text = datum.get(heading)76 if text:77 item = QtWidgets.QTableWidgetItem(text)78 self.snapshot.setItem(row_c, col_c, item)79 def clear_snapshot(self):80 self.snapshot.setColumnCount(0)81 self.snapshot.setRowCount(0)82 def toggle_snapshot(self, bool):83 self.show_snapshot = bool84 if not bool:85 self.clear_snapshot()86 @QtCore.pyqtSlot(Job)87 def set_job(self, job):88 self.job = job...

Full Screen

Full Screen

view.py

Source:view.py Github

copy

Full Screen

...7 @abstractmethod8 def show_test_specification(self, test_specification: TestSpecification, test_execution_id: str):9 """Zeigt die TestSpezifikation auf einer Benutzeroberfläche an"""10 @abstractmethod11 def show_snapshot(self, snapshot: Snapshot) -> None:12 """Zeigt einen Snapshot auf einer Benutzeroberfläche an"""13 @abstractmethod14 def show_evaluation_data_entry(self, evaluation_data_entry: EvaluationDataEntry):15 """Zeigt einen EvaluationDataEntry auf einer Benutzeroberfläche an"""16 @abstractmethod17 def show_total_result(self, total_result: TotalResult, test_execution_id: Optional[str] = None,18 simulation_run_number: Optional[int] = None):19 """Zeigt das Ergebnis einer Evaluation (TotalResult) auf einer Benutzeroberfläche an"""20class ConsoleView(AbstractView):21 def show_test_specification(self, test_specification: TestSpecification, test_execution_id: str):22 print(f"TestSpecification for TestExecution {test_execution_id}:")23 print(f"test_specification={test_specification}")24 def show_snapshot(self, snapshot: Snapshot) -> None:25 print(f"snapshot={snapshot}")26 def show_evaluation_data_entry(self, evaluation_data_entry: EvaluationDataEntry):27 print(f"evaluation_data_entry={evaluation_data_entry}")28 def show_total_result(self, total_result: TotalResult, test_execution_id: Optional[str] = None,29 simulation_run_number: Optional[int] = None):30 if simulation_run_number:31 print(f"TotalResult for simulation_run_number={simulation_run_number}:")32 elif test_execution_id:33 print(f"TotalResult for test_execution_id={test_execution_id}:")...

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 tempest 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