Best Python code snippet using SeleniumBase
MovieService.py
Source:MovieService.py
1from bson.json_util import dumps2from flask import request3from flask_restful import Resource4from src.resources.Messages import exclude_success_message, post_success_message, nodatas_message, update_success_message5import json6class AllMovies(Resource):7 def get(self):8 from src.app import db9 movies = json.loads(dumps(list(db['movies'].find())))10 if movies is None:11 return nodatas_message12 return movies13class MoviePerId(Resource):14 def get(self, id):15 from src.app import db16 movie = json.loads(dumps(db['movies'].find_one({"_id": id})))17 if movie is None:18 return nodatas_message19 return movie20 def put(self, id):21 from src.app import db22 title = request.json['title']23 description = request.json['description']24 movie = db['movies'].update_one({"_id": id}, {"$set": {"title": title, "description": description}})25 print(movie.raw_result)26 if movie.raw_result['n'] == 0:27 return nodatas_message28 return update_success_message29 def delete(self, id):30 from src.app import db31 movie = db['movies'].delete_one({"_id": id})32 print(movie.raw_result)33 if movie.raw_result['n'] == 0:34 return nodatas_message35 return exclude_success_message36class Movie(Resource):37 def post(self):38 from src.app import db39 title = request.json['title']40 description = request.json['description']41 db.movies.insert({"title": title, "description": description})...
config.py
Source:config.py
1import os2class AppConfig:3 CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))4 APP_PORT = 80805 APP_HOST = "0.0.0.0"6 DEBUG_MODE = False7class DiscordConfig:8 BOT_COMMAND_PREFIX = "!"9 DISCORD_WEBHOOK_URL = ""10 DISCORD_BOT_TOKEN = ""11 DISCORD_TARGET_GUILD = ""12 DISCORD_TARGET_CHANNEL = ""13class BotConfig:14 MESSAGE_TYPE_KEY_NAME = "type"15 MESSAGE_CONTENT_KEY_NAME = "content"16 MESSAGE_TYPE_MESSAGE_KEY_NAME = "message"17 FILE_TYPE_MESSAGE_KEY_NAME = "file"18 LOG_FILES_DIR_PATH = os.path.join(AppConfig.CURRENT_DIR, "logs")19 BOT_LOGS_FILE = os.path.join(LOG_FILES_DIR_PATH, "bot.txt")20class ApiConfig:21 AUTH_TOKEN = "test_auth_token"22 TOKEN_KEY_NAME = "auth_token"23 SENSOR_NAME_KEY_NAME = "sensor"24 POST_DATA_ENCODING = "utf-8"25 POST_FAILED_MESSAGE = "Failed"...
consts.py
Source:consts.py
1class ApiConsts:2 REQUESTS_ENCODING = "utf-8"3 POST_FAILED_MESSAGE = "FAIL"4 POST_SUCCESS_MESSAGE = "OK"5 AUTH_TOKEN_KEY_NAME = "auth_token"6 AUTH_TOKEN = "test_auth_token"7class DataConsts:8 TIME_KEY_NAME = "time"9 TEMPERATURE_KEY_NAME = "temperature"10 HUMIDITY_KEY_NAME = "humidity"11class DateConsts:12 HOUR_FORMATTING = "%H:%M:%S"...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!