Best Python code snippet using tempest_python
react_crud_config.py
Source:react_crud_config.py
1PATH_MODULE = "/Users/ioedu/projects/prj_eafpos/frontend/restrict/src/modules"2FOLDER_TEMPLATE = "zzz-tpl"3MODEL_REPLACES = {4 "zzz-tpls": "app-tables",5 "zzz-tpl": "app-table",6 "zzz_tpls": "app_tables",7 "zzz_tpl": "app_table",8 "ZzzTpls": "AppTables",9 "ZzzTpl": "AppTable",10 "Tpls": "Tables",11 "Tpl": "Table",12 "tpls": "tables",13 "tpl": "table"14}15FORM_REPLACES = {16 "FORM_CLONE": {17 "exclude": [18 "processflag",19 "insert_platform", "insert_user", "insert_date",20 "update_platform", "update_user", "update_date",21 "delete_platform", "delete_user", "delete_date",22 "cru_csvnote", "is_erpsent", "is_enabled",23 "i", "code_cache",24 "id", "id_user",25 ],26 },27 "FORM_DELETE": {28 "exclude": [29 "processflag",30 "insert_platform", "insert_user", "insert_date",31 "update_platform", "update_user", "update_date",32 "delete_platform", "delete_user", "delete_date",33 "cru_csvnote", "is_erpsent", "is_enabled",34 "i", "code_cache",35 "id", "id_user",36 ],37 },38 "FORM_DELETELOGIC": {39 "exclude": [40 "processflag",41 "insert_platform", "insert_user", "insert_date",42 "update_platform", "update_user", "update_date",43 "delete_platform", "delete_user", "delete_date",44 "cru_csvnote", "is_erpsent", "is_enabled",45 "i", "code_cache",46 "id", "id_user",47 ],48 },49 "FORM_DETAIL": {50 "exclude": [51 "processflag",52 "insert_platform", "insert_user", "insert_date",53 "update_platform", "update_user", "update_date",54 "delete_platform", "delete_user", "delete_date",55 "cru_csvnote", "is_erpsent", "is_enabled",56 "i",57 "id", "id_user",58 ],59 },60 "FORM_INSERT": {61 "exclude": [62 "processflag",63 "insert_platform", "insert_user", "insert_date",64 "update_platform", "update_user", "update_date",65 "delete_platform", "delete_user", "delete_date",66 "cru_csvnote", "is_erpsent", "is_enabled",67 "i", "code_cache",68 "id", "id_user",69 ],70 "defaults": {}71 },72 "FORM_UPDATE": {73 "exclude": [74 "processflag",75 "insert_platform", "insert_user", "insert_date",76 "update_platform", "update_user", "update_date",77 "delete_platform", "delete_user", "delete_date",78 "cru_csvnote", "is_erpsent", "is_enabled",79 "i", "code_cache",80 "id", "id_user"81 ],82 },83 "FORM_QUERY_ENTITY": {84 "exclude": [85 "processflag",86 "insert_platform", "insert_user", # "insert_date",87 "update_platform", "update_user", # "update_date",88 "delete_platform", "delete_user", # "delete_date",89 "cru_csvnote", "is_erpsent", # "is_enabled",90 "i",91 "code_cache",92 ],93 }94}95FIELD_REPLACES = {96 "FIELDS_CLONE": {97 "exclude": [98 "processflag",99 "insert_platform", "insert_user", "insert_date",100 "update_platform", "update_user", "update_date",101 "delete_platform", "delete_user", "delete_date",102 "cru_csvnote", "is_erpsent", "is_enabled",103 "i", "code_cache",104 "id", "id_user",105 ],106 },107 "FIELDS_DELETE": {108 "exclude": [109 "processflag",110 "insert_platform", "insert_user", "insert_date",111 "update_platform", "update_user", "update_date",112 "delete_platform", "delete_user", "delete_date",113 "cru_csvnote", "is_erpsent", "is_enabled",114 "i", "code_cache",115 "id", "id_user",116 ],117 },118 "FIELDS_DELETELOGIC": {119 "exclude": [120 "processflag",121 "insert_platform", "insert_user", "insert_date",122 "update_platform", "update_user", "update_date",123 "delete_platform", "delete_user", "delete_date",124 "cru_csvnote", "is_erpsent", "is_enabled",125 "i", "code_cache",126 "id", "id_user",127 ],128 },129 "FIELDS_DETAIL": {130 "exclude": [131 "processflag",132 "insert_platform", "insert_user", "insert_date",133 "update_platform", "update_user", "update_date",134 "delete_platform", "delete_user", "delete_date",135 "cru_csvnote", "is_erpsent", "is_enabled",136 "i",137 "id", "id_user",138 ],139 },140 "FIELDS_INSERT": {141 "exclude": [142 "processflag",143 "insert_platform", "insert_user", "insert_date",144 "update_platform", "update_user", "update_date",145 "delete_platform", "delete_user", "delete_date",146 "cru_csvnote", "is_erpsent", "is_enabled",147 "i", "code_cache",148 "id", "id_user",149 ],150 "defaults": {}151 },152 "FIELDS_UPDATE": {153 "exclude": [154 "processflag",155 "insert_platform", "insert_user", "insert_date",156 "update_platform", "update_user", "update_date",157 "delete_platform", "delete_user", "delete_date",158 "cru_csvnote", "is_erpsent", "is_enabled",159 "i", "code_cache",160 "id", "id_user"161 ],162 },163 "FIELDS_QUERY_LIST": {164 "exclude": [165 "processflag",166 "insert_platform", "insert_user", # "insert_date",167 "update_platform", "update_user", # "update_date",168 "delete_platform", "delete_user", # "delete_date",169 "cru_csvnote", "is_erpsent", # "is_enabled",170 "i",171 ],172 },173 "FIELDS_QUERY_ENTITY": {174 "exclude": [175 "processflag",176 "insert_platform", "insert_user", # "insert_date",177 "update_platform", "update_user", # "update_date",178 "delete_platform", "delete_user", # "delete_date",179 "cru_csvnote", "is_erpsent", # "is_enabled",180 "i",181 "code_cache",182 ],183 },184 "FIELDS_GRID_HEADERS": {185 # { text: 'Code', value: 'code_erp' },186 "exclude": [187 "processflag",188 "insert_platform", "insert_user", "insert_date",189 "update_platform", "update_user", "update_date",190 "delete_platform", "delete_user", "delete_date",191 "cru_csvnote", "is_erpsent", "is_enabled",192 "i",193 "id", "code_cache",194 ],195 },196 "FIELDS_FILTERCONF": {197 # {name: "id", labels:["n","n","id"]},198 "exclude": [199 "processflag",200 "insert_platform", "insert_user", "insert_date",201 "update_platform", "update_user", "update_date",202 "delete_platform", "delete_user", "delete_date",203 "cru_csvnote", "is_erpsent", "is_enabled",204 "i",205 "id", "code_cache",206 ],207 }208}209INPUTS_TPLS = {210 "FORM_CLONE":{211 "html": """212 <div className="col-12">213 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>214 <input type="text" className="form-control" id="txt-%field_name%"215 216 value={formdata.%field_name%}217 disabled 218 />219 </div>220 """,221 },222 "FORM_DELETE":{223 "html": """224 <div className="col-12">225 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>226 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%" 227 228 value={formdata.%field_name%}229 disabled 230 />231 </div>232 """233 },234 "FORM_DELETELOGIC":{235 "html": """236 <div className="col-12">237 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>238 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%" 239 240 value={formdata.%field_name%}241 disabled 242 />243 </div>244 """245 },246 "FORM_DETAIL":{247 "html": """248 <div className="row">249 <div className="col-6">label-%field_name%</div>250 <div className="col-6">{formdata.%field_name%}</div>251 </div>252 """253 },254 "FORM_INSERT":{255 "html": """256 <div className="col-12">257 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>258 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%"259 value={formdata.%field_name%}260 onChange={updateform}261 />262 </div> 263 """264 },265 "FORM_UPDATE":{266 "html": """267 <div className="col-12">268 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>269 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%"270 value={formdata.%field_name%}271 onChange={updateform}272 />273 </div> 274 """275 },276}277DEFAULT_VALUES_TYPES = {278 "int": 0,279 "tinyint": 0,280 "decimal": 0.00,281 "varchar": "\"\"",282 "datetime": "\"\"",283 "timestamp": "\"\"",...
marketing_crud_config.py
Source:marketing_crud_config.py
1PATH_MODULE = "/Users/ioedu/projects/prj_marketing/backend_web/src"2FOLDER_TEMPLATE = "zzz-tpl"3MODEL_REPLACES = {4 "zzz-tpls": "app-tables",5 "zzz-tpl": "app-table",6 "zzz_tpls": "app_tables",7 "zzz_tpl": "app_table",8 "ZzzTpls": "AppTables",9 "ZzzTpl": "AppTable",10 "Tpls": "Tables",11 "Tpl": "Table",12 "tpls": "tables",13 "tpl": "table"14}15FORM_REPLACES = {16 "FORM_CLONE": {17 "exclude": [18 "processflag",19 "insert_platform", "insert_user", "insert_date",20 "update_platform", "update_user", "update_date",21 "delete_platform", "delete_user", "delete_date",22 "cru_csvnote", "is_erpsent", "is_enabled",23 "i", "uuid",24 "id", "id_user",25 ],26 },27 "FORM_DELETE": {28 "exclude": [29 "processflag",30 "insert_platform", "insert_user", "insert_date",31 "update_platform", "update_user", "update_date",32 "delete_platform", "delete_user", "delete_date",33 "cru_csvnote", "is_erpsent", "is_enabled",34 "i", "uuid",35 "id", "id_user",36 ],37 },38 "FORM_DELETELOGIC": {39 "exclude": [40 "processflag",41 "insert_platform", "insert_user", "insert_date",42 "update_platform", "update_user", "update_date",43 "delete_platform", "delete_user", "delete_date",44 "cru_csvnote", "is_erpsent", "is_enabled",45 "i", "uuid",46 "id", "id_user",47 ],48 },49 "FORM_DETAIL": {50 "exclude": [51 "processflag",52 "insert_platform", "insert_user", "insert_date",53 "update_platform", "update_user", "update_date",54 "delete_platform", "delete_user", "delete_date",55 "cru_csvnote", "is_erpsent", "is_enabled",56 "i",57 "id", "id_user",58 ],59 },60 "FORM_INSERT": {61 "exclude": [62 "processflag",63 "insert_platform", "insert_user", "insert_date",64 "update_platform", "update_user", "update_date",65 "delete_platform", "delete_user", "delete_date",66 "cru_csvnote", "is_erpsent", "is_enabled",67 "i", "uuid",68 "id", "id_user",69 ],70 "defaults": {}71 },72 "FORM_UPDATE": {73 "exclude": [74 "processflag",75 "insert_platform", "insert_user", "insert_date",76 "update_platform", "update_user", "update_date",77 "delete_platform", "delete_user", "delete_date",78 "cru_csvnote", "is_erpsent", "is_enabled",79 "i", "uuid",80 "id", "id_user"81 ],82 },83 "FORM_QUERY_ENTITY": {84 "exclude": [85 "processflag",86 "insert_platform", "insert_user", # "insert_date",87 "update_platform", "update_user", # "update_date",88 "delete_platform", "delete_user", # "delete_date",89 "cru_csvnote", "is_erpsent", # "is_enabled",90 "i",91 "uuid",92 ],93 }94}95FIELD_REPLACES = {96 "FIELDS_CLONE": {97 "exclude": [98 "processflag",99 "insert_platform", "insert_user", "insert_date",100 "update_platform", "update_user", "update_date",101 "delete_platform", "delete_user", "delete_date",102 "cru_csvnote", "is_erpsent", "is_enabled",103 "i", "uuid",104 "id", "id_user",105 ],106 },107 "FIELDS_DELETE": {108 "exclude": [109 "processflag",110 "insert_platform", "insert_user", "insert_date",111 "update_platform", "update_user", "update_date",112 "delete_platform", "delete_user", "delete_date",113 "cru_csvnote", "is_erpsent", "is_enabled",114 "i", "uuid",115 "id", "id_user",116 ],117 },118 "FIELDS_DELETELOGIC": {119 "exclude": [120 "processflag",121 "insert_platform", "insert_user", "insert_date",122 "update_platform", "update_user", "update_date",123 "delete_platform", "delete_user", "delete_date",124 "cru_csvnote", "is_erpsent", "is_enabled",125 "i", "uuid",126 "id", "id_user",127 ],128 },129 "FIELDS_DETAIL": {130 "exclude": [131 "processflag",132 "insert_platform", "insert_user", "insert_date",133 "update_platform", "update_user", "update_date",134 "delete_platform", "delete_user", "delete_date",135 "cru_csvnote", "is_erpsent", "is_enabled",136 "i",137 "id", "id_user",138 ],139 },140 "FIELDS_INSERT": {141 "exclude": [142 "processflag",143 "insert_platform", "insert_user", "insert_date",144 "update_platform", "update_user", "update_date",145 "delete_platform", "delete_user", "delete_date",146 "cru_csvnote", "is_erpsent", "is_enabled",147 "i", "uuid",148 "id", "id_user",149 ],150 "defaults": {}151 },152 "FIELDS_UPDATE": {153 "exclude": [154 "processflag",155 "insert_platform", "insert_user", "insert_date",156 "update_platform", "update_user", "update_date",157 "delete_platform", "delete_user", "delete_date",158 "cru_csvnote", "is_erpsent", "is_enabled",159 "i", "uuid",160 "id", "id_user"161 ],162 },163 "FIELDS_QUERY_LIST": {164 "exclude": [165 "processflag",166 "insert_platform", "insert_user", # "insert_date",167 "update_platform", "update_user", # "update_date",168 "delete_platform", "delete_user", # "delete_date",169 "cru_csvnote", "is_erpsent", # "is_enabled",170 "i",171 ],172 },173 "FIELDS_QUERY_ENTITY": {174 "exclude": [175 "processflag",176 "insert_platform", "insert_user", # "insert_date",177 "update_platform", "update_user", # "update_date",178 "delete_platform", "delete_user", # "delete_date",179 "cru_csvnote", "is_erpsent", # "is_enabled",180 "i",181 "uuid",182 ],183 },184 "FIELDS_GRID_HEADERS": {185 # { text: 'Code', value: 'code_erp' },186 "exclude": [187 "processflag",188 "insert_platform", "insert_user", "insert_date",189 "update_platform", "update_user", "update_date",190 "delete_platform", "delete_user", "delete_date",191 "cru_csvnote", "is_erpsent", "is_enabled",192 "i",193 "id", "uuid",194 ],195 },196 "FIELDS_FILTERCONF": {197 # {name: "id", labels:["n","n","id"]},198 "exclude": [199 "processflag",200 "insert_platform", "insert_user", "insert_date",201 "update_platform", "update_user", "update_date",202 "delete_platform", "delete_user", "delete_date",203 "cru_csvnote", "is_erpsent", "is_enabled",204 "i",205 "id", "uuid",206 ],207 }208}209INPUTS_TPLS = {210 "FORM_CLONE":{211 "html": """212 <div className="col-12">213 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>214 <input type="text" className="form-control" id="txt-%field_name%"215 216 value={formdata.%field_name%}217 disabled 218 />219 </div>220 """,221 },222 "FORM_DELETE":{223 "html": """224 <div className="col-12">225 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>226 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%" 227 228 value={formdata.%field_name%}229 disabled 230 />231 </div>232 """233 },234 "FORM_DELETELOGIC":{235 "html": """236 <div className="col-12">237 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>238 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%" 239 240 value={formdata.%field_name%}241 disabled 242 />243 </div>244 """245 },246 "FORM_DETAIL":{247 "html": """248 <div className="row">249 <div className="col-6">label-%field_name%</div>250 <div className="col-6">{formdata.%field_name%}</div>251 </div>252 """253 },254 "FORM_INSERT":{255 "html": """256 <div className="col-12">257 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>258 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%"259 value={formdata.%field_name%}260 onChange={updateform}261 />262 </div> 263 """264 },265 "FORM_UPDATE":{266 "html": """267 <div className="col-12">268 <label htmlFor="txt-%field_name%" className="form-label">label-%field_name%</label>269 <input type="text" className="form-control" id="txt-%field_name%" placeholder="placeholder-%field_name%"270 value={formdata.%field_name%}271 onChange={updateform}272 />273 </div> 274 """275 },276}277DEFAULT_VALUES_TYPES = {278 "int": 0,279 "tinyint": 0,280 "decimal": 0.00,281 "varchar": "\"\"",282 "datetime": "\"\"",283 "timestamp": "\"\"",...
user_profile_controller.py
Source:user_profile_controller.py
1# -*- coding: utf-8 -*-2#!/usr/bin/env python3import base644import datetime5import logging6from app_controller import BaseHandler7from app.models.user import UserModel8from config.jinja_environment import JINJA_ENVIRONMENT9class ProfilePanelHandler(BaseHandler):10 def get(self):11 user = None12 user = self.session['user']13 context = { 'data': user, }14 template = JINJA_ENVIRONMENT.get_template('user/profile.html')15 self.response.write(template.render(context))16class UpdateProfilePanelHandler(BaseHandler):17 def get(self):18 user = None19 user = self.session['user']20 first_name = self.request.get('first_name')21 last_name = self.request.get('last_name')22 if first_name and last_name:23 update_user = UserModel.get_user(user['email'])24 update_user.first_name = first_name25 update_user.last_name = last_name26 update_user.put()27 session_user = {28 'first_name': update_user.first_name,29 'last_name': update_user.last_name,30 'email': update_user.email,31 'is_admin': update_user.is_admin,32 'enterprise': update_user.enterprise,33 'is_custom_user': update_user.is_custom_user,34 }35 self.session['user'] = session_user36 self.response.write({'response': 'ok'})37 else:38 self.response.write({'response': 'fail'})39class UpdatePasswordProfilePanelHandler(BaseHandler):40 def get(self):41 user = None42 user = self.session['user']43 old_pass = self.request.get('old_pass')44 new_pass1 = self.request.get('new_pass1')45 new_pass2 = self.request.get('new_pass2')46 if old_pass and new_pass1 and new_pass2:47 update_user = UserModel.get_user(user['email'])48 update_user.first_name = first_name49 update_user.last_name = last_name50 update_user.put()51 session_user = {52 'first_name': update_user.first_name,53 'last_name': update_user.last_name,54 'email': update_user.email,55 'is_admin': update_user.is_admin,56 'enterprise': update_user.enterprise,57 'is_custom_user': update_user.is_custom_user,58 }59 self.session['user'] = session_user60 self.response.write({'response': 'ok'})61 else:62 self.response.write({'response': 'fail'})63class TestInputWithUserAndPassword(BaseHandler):64 def get(self):65 logging.info(self.request.headers)66 logging.info(self.request.body)67 headers = self.request.headers68 auth = headers['Authorization']69 logging.info(auth)70 auth = re.sub('^Basic ', '', auth)71 user, password = base64.decodestring(auth).split(':')72 logging.info(user)73 logging.info(password)74class LoginPanelHandler(BaseHandler):75 def get(self):76 template = JINJA_ENVIRONMENT.get_template('user/login.html')77 self.response.write(template.render())78 def post(self):79 email = self.request.get('email')80 password = self.request.get('password')81 current_user = UserModel()82 if email and password:83 password = base64.b64encode(password)84 this_user = current_user.get_user(email)85 if this_user.password == password:86 user = {87 'first_name': this_user.first_name,88 'last_name': this_user.last_name,89 'email': this_user.email,90 'is_admin': this_user.is_admin,91 'enterprise': this_user.enterprise,92 'is_custom_user': this_user.is_custom_user,93 }94 self.session['user'] = user95 self.redirect('/')96 else:97 self.redirect('/login/')98 else:99 self.redirect('/login/')100class LogoutPanelHandler(BaseHandler):101 def get(self):102 try:103 del self.session['user']104 except:105 pass...
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!!