How to use matching method in Selene

Best Python code snippet using selene_python

views.py

Source: views.py Github

copy

Full Screen

...33 return render(request, "detail_matching.html", content)34# matching 삭제35# 해당 matching의 작성자인지 확인해야 함36# matching/​delete_matching/​<tattooist_id: int>/​<matching_id: int>37def delete_matching(request, tattooist_id: int, matching_id: int):38 matching = Matching.objects.get(pk=matching_id)39 # 만약 로그인하지 않았거나, 작성자가 아닌 경우40 if not request.user.is_authenticated or request.user.id != matching.author.id:41 return redirect("customer_request_rejected")42 matching.delete()43 return redirect("matching_list")44# customer가 tattooist만 접근 가능한 기능에 접근하는 경우45def customer_request_rejected_view(request):46 return render(request, "customer_request_rejected.html")47# 조건에 맞는 matching의 리스트를 pagination으로 보여주는 페이지48# matching/​matching_list?region=인천&type=미니타투&part=목&order-by=price(또는 pub-date)49def matching_list_view(request):50 content = dict()51 content["is_tattooist"] = (request.user.is_authenticated) and (request.user.is_tattooist)...

Full Screen

Full Screen

matching.py

Source: matching.py Github

copy

Full Screen

1#!/​usr/​bin/​env python32# *-* coding:utf8 *-*3# sky4from lib import database, log, warning, notification5import os, datetime, re6def matching_record(logger, db, record_time, matching_file, matching_key):7 logger.logger.debug(f"记录匹配({matching_file}:{matching_key})信息...")8 with open(matching_file, "r") as f:9 sql="select record_filesize from matching where record_time=(select max(record_time) from matching where matching_file=? and matching_key=?) and matching_file=? and matching_key=?"10 record_filesize=db.query_one(sql, (matching_file, matching_key, matching_file, matching_key))[0]11 now_filesize=os.stat(matching_file)[6]12 #logger.logger.info(f"{matching_file=}, {record_filesize=}, {now_filesize=}")13 if now_filesize < record_filesize:14 record_filesize=015 elif now_filesize == record_filesize:16 return17 f.seek(record_filesize)18 lines=f.readlines()19 next_filesize=f.tell()20 #logger.logger.info(f"{matching_file=}, {record_filesize=}, {lines=}, {next_filesize=}")21 warning_flag=022 sql="insert into matching values(?, ?, ?, ?, ?)"23 for line in lines:24 if re.search(matching_key, line):25 warning_flag=126 #logger.logger.warning(f"{matching_file}文件中出现{matching_key}")27 db.update_one(sql, (record_time, matching_file, matching_key, line, next_filesize))28 if warning_flag==0:29 db.update_one(sql, (record_time, matching_file, matching_key, "Nothing", next_filesize))30def matching_records(log_file, log_level, matching_dict):31 logger=log.Logger(log_file, log_level)32 db=database.db()33 record_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")34 for i in matching_dict:35 matching_record(logger, db, record_time, i, matching_dict[i])36def matching_analysis(log_file, log_level, warning_interval, matching_dict, notify_dict):37 logger=log.Logger(log_file, log_level)38 db=database.db()39 for matching_file in matching_dict:40 sql=f"select record_time, matching_context from matching \41 where record_time=( \42 select max(record_time) from matching \43 where matching_context!=? and matching_file=? and matching_key=?\44 )"45 data=db.query_one(sql, ("all", matching_file, matching_dict[matching_file]))46 logger.logger.debug("分析匹配...")47 if data is not None:48 if data[1] != 'Nothing':49 warning_msg=f"\"{matching_file}\"文件中\"{data[1].strip()}\"行存在关键字\"{matching_dict[matching_file]}\""50 msg=f"{matching_file}_{matching_dict[matching_file]}"51 warning_flag=warning.non_remedial_warning(logger, db, "matching", msg, warning_msg, data[0], warning_interval)52 if warning_flag:53 warning_msg=f"日志分析预警:\n{warning_msg}\n"54 notification.send(logger, warning_msg, notify_dict, msg=msg)55if __name__ == "__main__":...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Migrating Test Automation Suite To Cypress 10

There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Testing Modern Applications With Playwright ????

Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

Unveiling Samsung Galaxy Z Fold4 For Mobile App Testing

Hey LambdaTesters! We’ve got something special for you this week. ????

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