How to use report_in_progress method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

reporttests.py

Source:reporttests.py Github

copy

Full Screen

...368 report.start_time = time.time()369 report.end_time = report.start_time370 report.saving_time = report.start_time371 self.do_test_report_serialization(report)372 def test_report_in_progress(self, report_in_progress):...

Full Screen

Full Screen

client.py

Source:client.py Github

copy

Full Screen

...112 hl()113 report_finished('rejected', rejected)114 if len(in_progress) > 0:115 hl()116 report_in_progress(in_progress)117def report_inbox(ids: List[str]):118 log.info("Patches waiting in Inbox:")119 for patch_id in ids:120 description = Path('%s/inbox/%s.txt' % (BASE_DIR, patch_id)).read_text()121 log.info(" -> %s - %s" % (patch_id, description))122def report_in_progress(ids: List[str]):123 log.info("Currently running verification:")124 for patch_id in ids:125 description = Path('%s/inbox/%s.txt' % (BASE_DIR, patch_id)).read_text()126 log.info(" - %s - %s" % (patch_id, description))127 log.info("")128 if Path('%s/work/%s.STC.result' % (BASE_DIR, patch_id)).exists():129 report_ongoing_result('STC', patch_id)130 if Path('%s/work/%s.LTC.result' % (BASE_DIR, patch_id)).exists():131 report_ongoing_result('LTC', patch_id)132 hl()133def report_finished(result: str, ids: List[str]):134 log.info("%s patches:" % result.capitalize())135 for patch_id in ids:136 with tarfile.open('%s/%s/%s.tar.gz' % (BASE_DIR, result, patch_id)) as tar:...

Full Screen

Full Screen

receivers.py

Source:receivers.py Github

copy

Full Screen

1from django.dispatch import receiver2from settings import NTD_KEYWORDS3from rapidsms_xforms.models import xform_received4import datetime5def handle_parish(xform, submission, health_provider):6 from .utils import parse_location7 if (xform.keyword != 'par') or submission.has_errors:8 return9 p_eav=submission.eav.ntd_parish10 reporter=Reporter.objects.get(healthprovider_ptr=health_provider)11 parish=parse_location(p_eav,"parish")12 if not parish :13 submission.response = 'You are attempting to report for parish "{0}" which does not exist.'.format(submission.eav.ntd_parish)14 submission.has_errors = True15 submission.save()16 elif parish not in reporter.subcounty.get_children():17 submission.response = 'The parish "{0}" is not in your subcounty'.format(submission.eav.ntd_parish)18 submission.has_errors = True19 submission.save()20def update_report(report,xform):21 pass22def generate_report(xform, submission, health_provider):23 reporter=Reporter.objects.get(health_provider_ptr=health_provider)24 report=NTDReport.objects.get_or_create(reporter=reporter)25 return True26def default_constraint(xform, submission, health_provider):27 return True28def handle_parish(xform, submission, reporter):29 return True30def handle_villages_targeted(xform, submission, reporter):31 return True32def handle_schools_targeted(xform, submission, reporter):33 return True34def handle_treated(xform, submission, reporter):35 return True36def handle_pop(xform, submission, reporter):37 return True38def handle_drugs_used(xform, submission, reporter):39 return True40def handle_drugs_left(xform, submission, reporter):41 return True42xform_constraints={43 "ntd_parish":handle_parish,44"ntd_villages_targeted":handle_villages_targeted,45"ntd_schools_targeted":handle_schools_targeted,46"ntd_treated_by_age":handle_treated,47"ntd_village_pop_by_age":handle_pop,48"ntd_drugs_used":handle_drugs_used,49"ntd_drugs_left":handle_drugs_left50}51@receiver(xform_received)52def handle_submission(sender, **kwargs):53 from rapidsms_xforms.models import xform_received,XFormReport54 from .models import ReportProgress,Reporter,NTDReport55 xform = kwargs['xform']56 if not xform.keyword in NTD_KEYWORDS:57 return58 submission = kwargs['submission']59 if submission.has_errors:60 return61 try:62 health_provider = submission.connection.contact.healthproviderbase.healthprovider63 except:64 if xform.keyword in NTD_KEYWORDS:65 submission.response = "You must be a reporter for NTDS. Please register first before sending any information"66 submission.has_errors = True67 submission.save()68 return69 if not xform.keyword in ['par']:70 report_in_progress = ReportProgress.objects.filter(provider=health_provider,status=1)71 if not report_in_progress.exists():72 submission.response = "Please tell us what POW you are reporting for before submitting data."73 submission.has_errors = True74 submission.save()75 return76 if xform.keyword in NTD_KEYWORDS and not (xform.keyword in ['par']):77 value_list = []78 for v in submission.eav.get_values().order_by('attribute__xformfield__order'):79 value_list.append("%s %d" % (v.attribute.name, v.value_int))80 if len(value_list) > 1:81 value_list[len(value_list) - 1] = " and %s" % value_list[len(value_list) - 1]82 health_provider.last_reporting_date = datetime.datetime.now().date()83 health_provider.save()84 try:85 health_provider.facility.last_reporting_date = datetime.datetime.now().date()86 health_provider.facility.save()87 except:88 pass89 submission.response = "You reported %s.If there is an error,please resend." % ','.join(value_list)90 submission.save()91 if not xform.keyword in ['par']:92 report_in_progress.xform_report.submissions.add(submission)93 report_in_progress.xform_report.save() # i may not need this94 submission.save()95 else:96 ## 4. -> process constraints from the DB (pow handler)97 for c in XFormReport.objects.get(name='NTDs').constraints:98 # WARNING: I'm (intentionally) not catching KeyError exceptions so all constraints must exist...

Full Screen

Full Screen

api_wordstate.py

Source:api_wordstate.py Github

copy

Full Screen

1import json2import os3import time4import requests5import service_file6TEST = True7# 157 - Минск8GEO = [157] 9TOKEN = 'AQAAAAAMgF1ZAAcdzwm7PJYIOEe3kePaA-goJvU' # https://oauth.yandex.ru/authorize?response_type=token&client_id=5ea6147df53b46189b22da46c3b10618 #ид приложения10if TEST:11 API_URL = 'https://api-sandbox.direct.yandex.ru/live/v4/json/' 12else:13 API_URL = 'https://api.direct.yandex.ru/v4/json/'14def request_to_api(query):15 temporary_error = 5216 payload = json.dumps(query, ensure_ascii=False).encode('utf-8')17 for attempt in range(10):18 try:19 response = requests.post(API_URL, payload)20 resp_json = response.json()21 if "error_code" in resp_json:22 if resp_json["error_code"] == temporary_error:23 time.sleep(2)24 return request_to_api(query)25 time.sleep(1)26 return resp_json27 except requests.exceptions.ConnectionError:28 print("Fail request to wordstat")29 print(f"Retry request to wordstat, attempt: {attempt}")30 raise Exception("Fail request to wordstat")31#ID: 5ea6147df53b46189b22da46c3b1061832#Password: 5a246d11e259442187c8cfde0144f97333#Callback URL: https://oauth.yandex.com/verification_code34# https://yandex.ru/dev/direct/doc/dg-v4/reference/CreateNewWordstatReport.html35# создание отчёта36def create_wordstat_report(phrases):37 query = {38 "method": "CreateNewForecast",39 "param": {40 "Phrases":phrases,41 "GeoID": GEO,42 "Currency": "RUB",43 },44 "token": TOKEN,45 "locale": "ru",46 }47 result = request_to_api(query)48 if result.get('error_str'):49 print(result)50 raise Exception('Error create_wordstat_report')51 return result52# получение отчёта53def get_wordstat_report(id_):54 report_in_progress = 7455 query = {56 "method": "GetForecast",57 "param": id_,58 "token": TOKEN,59 "locale": "ru",60 }61 resp_json = request_to_api(query)62 '''63 'Clicks':264 'Phrase':'наращивание ресниц рассрочку Минск'65 'Shows':166 'PremiumMin':73.367 'CTR':10068 'Min':5.5769 'PremiumCTR':10070 'PremiumClicks':271 'Currency':'RUB'72 'PremiumMax':73.373 'FirstPlaceClicks':274 'FirstPlaceCTR':10075 '''76 if "error_code" not in resp_json:77 delete_wordstat_report(id_)78 phrases = []79 for phrase in resp_json["data"]["Phrases"]:80 phrases.append((phrase["Phrase"], phrase["Shows"]))81 return phrases82 elif resp_json['error_code'] == report_in_progress:83 time.sleep(5)84 return get_wordstat_report(id_)85 86 else:87 delete_wordstat_report(id_)88 raise RuntimeError(resp_json)89# удаление отчета аналитики90def delete_wordstat_report(id_):91 query = {92 "method": "DeleteForecastReport",93 "param": id_,94 "token": TOKEN95 }96 response = request_to_api(query)97 if response["data"] == 1: # 1 - отчет успешно удалён98 return99 else:100 print(response)101 raise RuntimeError(response)102def get_regions():103 result = request_to_api({"method": "GetRegions", "token":TOKEN})104 service_file.save_json(result, 'regions')105 return result106 #editXML('result.xml')107 108if __name__ == '__main__':109 get_regions() #create_wordstat_report()...

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