How to use to_dict method in Slash

Best Python code snippet using slash

app.py

Source:app.py Github

copy

Full Screen

...67 m = []68 e = []69 char_ref = fb.collection('search').document('chara')70 chac = char_ref.get()71 m=(chac.to_dict()['tag'])72 print(m)73 #timestamp = datetime.datetime(2017, 12, 1, 0, 0).timestamp()74 file_url=""75 if request.method == "POST": # Only listen to POST76 result = request.form # Get the data submitted77 caption = result["caption"]78 characteristic = result["characteristic"]79 characteristic=characteristic.split(",")80 characteristic = [each_string.lower() for each_string in characteristic]81 m=m+characteristic82 l=set(m)83 m=l84 try:85 if request.method == 'POST':86 # check if the post request has the file part87 file = request.files['file']88 # If the user does not select a file, the browser submits an89 # empty file without a filename.90 if file.filename == '':91 flash('No selected file')92 return redirect(request.url)93 if file and allowed_file(file.filename):94 filename = secure_filename(file.filename)95 file.save(os.path.join(app.config['UPLOADED_PHOTOS_DEST'], filename))96 path_local = app.config['UPLOADED_PHOTOS_DEST'] + "/" + filename97 path_on_cloud = "photos/" + uid + "/" + str(hash(path_local)) + ".jpg"98 storage.child(path_on_cloud).put(path_local)99 file_url = storage.child("photos/" + uid + "/" + str(hash(path_local)) + ".jpg").get_url(100 None)101 doc_ref = fb.collection(uid).document(str(hash(path_local)))102 pub_ref = fb.collection('posts').document(str(hash(path_local)))103 print(m)104 image = Image.open(path_local)105 q = []106 # extracting the exif metadata107 exifdata = image.getexif()108 # doc_ref.set({109 # u'url':file_url,110 # u'caption':caption,111 # u'timestamp': firestore.SERVER_TIMESTAMP,112 # u'metadata':e113 #114 # })115 # looping through all the tags present in exifdata116 for tagid in exifdata:117 # getting the tag name instead of tag id118 tagname = TAGS.get(tagid, tagid)119 # passing the tagid to get its respective value120 value = exifdata.get(tagid)121 # printing the final result122 s = f"{tagname:24}:{value}"123 if (tagname != "MakerNote" and tagname != "UserComment"):124 e.append(s)125 print(s)126 print(e)127 doc_ref.set({128 u'url': file_url,129 u'caption': caption,130 u'timestamp': firestore.SERVER_TIMESTAMP,131 u'metadata': e,132 u'characteristic': characteristic,133 u'user': uid134 })135 pub_ref.set({136 u'url': file_url,137 u'caption': caption,138 u'timestamp': firestore.SERVER_TIMESTAMP,139 u'metadata': e,140 u'characteristic': characteristic,141 u'user': uid142 })143 char_ref.set({144 u'tag':m145 })146 for s in characteristic:147 chac_ref = fb.collection(s.lower()).document(str(hash(path_local)))148 chac_ref.set({149 u'url': file_url,150 u'caption': caption,151 u'timestamp': firestore.SERVER_TIMESTAMP,152 u'metadata': e,153 u'characteristic': characteristic,154 u'user': uid155 })156 success = True157 else:158 success = False159 except:160 #If there is any error, redirect back to login161 return redirect(url_for('welcome',_external=True,user=uid))162 return render_template("create.html", file_url=file_url,user=uid,metadata=e)163@app.route("/posts/<user>",methods=["POST","GET"])164def posts(user):165 uid=user166 u = fb.collection('posts')167 d = u.stream()168 a = []169 c = []170 t = []171 m = []172 key=[]173 usernames=[]174 user_emails=[]175 user_profiles=[]176 char_ref = fb.collection('search').document('chara')177 chac = char_ref.get()178 chac=(chac.to_dict()['tag'])179 print(chac)180 for doc in d:181 key.append(str(doc.id))182 print(doc.id)183 a.append(u'{}'.format(doc.to_dict()['url']))184 c.append(u'{}'.format(doc.to_dict()['caption']))185 t.append(u'{}'.format(doc.to_dict()['timestamp']))186 m.append(doc.to_dict()['metadata'])187 id = u'{}'.format(doc.to_dict()[u'user'])188 users_ref = fb.collection(u'users').document(id)189 user_doc = users_ref.get()190 name = u'{}'.format(user_doc.to_dict()['name'])191 usernames.append(name)192 email = u'{}'.format(user_doc.to_dict()['email'])193 user_emails.append(email)194 profile = u'{}'.format(user_doc.to_dict()['profile_url'])195 user_profiles.append(profile)196 print(u'{}'.format(doc.to_dict()['url']))197 print(m)198 if request.method == "POST":199 a = []200 c = []201 t = []202 m = []203 usernames = []204 user_emails = []205 user_profiles = []206 # Only listen to POST207 result = request.form # Get the data submitted208 tag = result["tag"]209 print(tag)210 tagname= fb.collection(tag)211 k= tagname.stream()212 for doc in k:213 key.append(doc.id)214 a.append(u'{}'.format(doc.to_dict()['url']))215 c.append(u'{}'.format(doc.to_dict()['caption']))216 t.append(u'{}'.format(doc.to_dict()['timestamp']))217 m.append(doc.to_dict()['metadata'])218 id=u'{}'.format(doc.to_dict()[u'user'])219 users_ref = fb.collection(u'users').document(id)220 user_doc = users_ref.get()221 name = u'{}'.format(user_doc.to_dict()['name'])222 usernames.append(name)223 email = u'{}'.format(user_doc.to_dict()['email'])224 user_emails.append(email)225 profile = u'{}'.format(user_doc.to_dict()['profile_url'])226 user_profiles.append(profile)227 print(u'{}'.format(doc.to_dict()['url']))228 print(m)229 return render_template("posts.html",files_list=a,caption=c,timestamps=t,metadata=m,l=len(a),user=uid,usernames=usernames,user_emails=user_emails,user_profiles=user_profiles,tags=chac,key=key)230@app.route("/details/<user>/<key>",methods=["POST","GET"])231def details(key,user):232 m=[]233 uid=user234 doc_ref = fb.collection(u'posts').document(key)235 doc = doc_ref.get()236 a=u'{}'.format(doc.to_dict()['url'])237 c=u'{}'.format(doc.to_dict()['caption'])238 t=u'{}'.format(doc.to_dict()['timestamp'])239 image_location =a240 m.append(doc.to_dict()['metadata'])241 id = u'{}'.format(doc.to_dict()[u'user'])242 users_ref = fb.collection(u'users').document(id)243 user_doc = users_ref.get()244 name = u'{}'.format(user_doc.to_dict()['name'])245 email = u'{}'.format(user_doc.to_dict()['email'])246 profile = u'{}'.format(user_doc.to_dict()['profile_url'])247 print(u'{}'.format(doc.to_dict()['url']))248 print(m)249 return render_template("details.html", file=a, caption=c, timestamps=t, metadata=m, l=len(a), user=uid,250 username=name, user_email=email, user_profile=profile,251 key=key)252@app.route("/delete/<user>/<key>",methods=["POST","GET"])253def delete(user,key):254 uid=user255 doc_ref = fb.collection(u'posts').document(key)256 doc_ref_1=fb.collection(uid).document(key)257 c= doc_ref.get().to_dict()['characteristic']258 print(c)259 fb.collection(u'posts').document(key).delete()260 fb.collection(uid).document(key).delete()261 for i in c:262 fb.collection(i).document(key).delete()263 return redirect(url_for('welcome',_external=True,user=uid))264#Welcome page265@app.route("/welcome/<user>",methods=["POST","GET"])266def welcome(user):267 key=[]268 for f in os.listdir('uploads'):269 if f.endswith('.jpg'):270 os.remove(os.path.join('uploads', f))271 filename=""272 path_local=""273 person["is_logged_in"] == True274 if person["is_logged_in"] == True:275 doc_ref = fb.collection(u'users').document(user)276 file_url = storage.child("avtars/" + user + ".jpg").get_url(None)277 users_ref = fb.collection(u'users').document(user)278 profile_url = storage.child("avtars/" + user + ".jpg").get_url(None)279 doc = doc_ref.get()280 # name = u'{}'.format(doc.to_dict()['name'])281 # email=u'{}'.format(doc.to_dict()['email'])282 # profile=u'{}'.format(doc.to_dict()['profile_url'])283 # form = UploadForm()284 if request.method == 'POST':285 # check if the post request has the file part286 file = request.files['file']287 # If the user does not select a file, the browser submits an288 # empty file without a filename.289 if file.filename == '':290 flash('No selected file')291 return redirect(request.url)292 if file and allowed_file(file.filename):293 filename = secure_filename(file.filename)294 file.save(os.path.join(app.config['UPLOADED_PHOTOS_DEST'], filename))295 path_local = app.config['UPLOADED_PHOTOS_DEST'] + "/" + filename296 path_on_cloud = "avtars/" + user + ".jpg"297 storage.child(path_on_cloud).put(path_local)298 file_url = storage.child("avtars/" + user + ".jpg").get_url(None)299 doc_ref.update({300 u'profile_url': file_url301 })302 # doc_ref.set({303 # u'name': name,304 # u'email': email,305 # u'profile_url': file_url,306 #307 # })308 os.remove(app.config['UPLOADED_PHOTOS_DEST']+"/"+ filename)309 success = True310 else:311 success = False312 #files_list = os.listdir(app.config['UPLOADED_PHOTOS_DEST'])313 #file_url = photos.url(filename)314 #profile_url=storage.child("avtars/"+person["uid"]+".jpg").get_url(None)315 u = fb.collection(user)316 d = u.stream()317 a=[]318 c=[]319 t=[]320 m=[]321 for doc in d:322 key.append(str(doc.id))323 a.append(u'{}'.format(doc.to_dict()['url']))324 c.append(u'{}'.format(doc.to_dict()['caption']))325 t.append(u'{}'.format(doc.to_dict()['timestamp']))326 m.append(doc.to_dict()['metadata'])327 print(u'{}'.format(doc.to_dict()['url']))328 print(m)329 doc = doc_ref.get()330 name = u'{}'.format(doc.to_dict()['name'])331 email=u'{}'.format(doc.to_dict()['email'])332 profile=u'{}'.format(doc.to_dict()['profile_url'])333 print(name,email,profile)334 return render_template("welcome.html", key=key,email = email, name = name,uid=user,file_url=profile,files_list=a,caption=c,timestamps=t,metadata=m,l=len(a),d=d)335 else:336 return redirect(url_for('login',_external=True))337#If someone clicks on login, they are redirected to /result338@app.route("/result", methods = ["POST", "GET"])339def result():340 trigger=False341 if request.method == "POST": #Only if data has been posted342 result = request.form #Get the data343 email = result["email"]344 password = result["pass"]345 try:346 #Try signing in the user with the given information347 user = auth.sign_in_with_email_and_password(email, password)348 #Insert the user data in the global person349 global person350 person["is_logged_in"] = True351 # person["email"] = user["email"]352 # person["uid"] = user["localId"]353 # person["idToken"] = user["idToken"]354 #Get the name of the user355 # users_ref = fb.collection(u'users').document(user['localId'])356 # doc = users_ref.get()357 # bal = u'{}'.format(doc.to_dict()['name'])358 # print(bal)359 #360 # data = db.child("users").get()361 # person["name"] = u'{}'.format(doc.to_dict()['name'])362 # person["email"]=u'{}'.format(doc.to_dict()['email'])363 # return render_template('login.html',trigger=person["is_logged_in"])364 return redirect(url_for('welcome',_external=True,user=user["localId"]))365 except:366 #If there is any error, redirect back to login367 return redirect(url_for('login',_external=True))368 # else:369 # if person["is_logged_in"] == True:370 #371 # return redirect(url_for('welcome',_external=True))372 # else:373 # return redirect(url_for('login',_external=True))374#If someone clicks on register, they are redirected to /register375@app.route("/register", methods = ["POST", "GET"])376def register():...

Full Screen

Full Screen

functions.py

Source:functions.py Github

copy

Full Screen

...4 5 def __init__(self, assigmentId):6 doc_ref = db.collection(u'assigments').document(assigmentId)7 doc = doc_ref.get()8 self.examId = doc.to_dict().get('examId')9 self.courseId = doc.to_dict().get('courseId')10 11 12 #self.examId = doc.to_dict().get('examId')13 # data = [{14 # "id" : doc.id, 15 # "Tipo" : doc.to_dict().get('Tipo'), 16 # "courseId" : doc.to_dict().get('courseId'),17 # "examId" : doc.to_dict().get('examId'),18 # "nombreExam" : doc.to_dict().get('nombreExam'),19 # "state" : doc.to_dict().get('state'),20 # "userId" : doc.to_dict().get('userId') 21 # }]22 def getAnswers(self):23 data = []24 students = users(self.courseId)25 for student in students:26 if self._getAnswers(student['id']).to_dict() is not None:27 data.append({'name':student['name']+' '+student['surname'],'answers':self._getAnswers(student['id']).to_dict()})28 29 return data30 def _getAnswers(self, userId):31 doc_ref = db.collection(u'user').document(userId).collection(u'answers').document(self.examId)32 doc = doc_ref.get()33 34 return doc35 36 def getAnswersStudent(self, idUser):37 data = []38 doc_ref = db.collection(u'user').document(idUser)39 doc = doc_ref.get()40 if self._getAnswers(idUser).to_dict() is not None:41 data.append({'name':doc.to_dict().get('name')+' '+doc.to_dict().get('surname'),'answers':self._getAnswers(idUser).to_dict()})42 return data43class Exam():44 def __init__(self, examId):45 self.examId = examId46 self.questions = self._questions()47 def _questions(self):48 docs = db.collection(u'question').where(u'idEvaluacion', u'==', self.examId).stream()49 50 data = [] 51 52 for doc in docs:53 54 data.append({55 "id" : doc.id, 56 "RespuestaA" : doc.to_dict().get('RespuestaA'),57 "RespuestaB" : doc.to_dict().get('RespuestaB'),58 "RespuestaC" : doc.to_dict().get('RespuestaC'),59 "RespuestaD" : doc.to_dict().get('RespuestaD'),60 "code" : doc.to_dict().get('code'),61 "dominio" : doc.to_dict().get('dominio'),62 "eje" : doc.to_dict().get('eje'),63 "habilidad" : doc.to_dict().get('habilidad'),64 "idEvaluacion" : doc.to_dict().get('idEvaluacion'),65 "ie" : doc.to_dict().get('ie'),66 "level" : doc.to_dict().get('level'),67 "oa" : doc.to_dict().get('oa'),68 "orderInt" : int(doc.to_dict().get('order')),69 "order" : doc.to_dict().get('order'),70 "owner" : doc.to_dict().get('owner'),71 "respuestaCorrecta" : doc.to_dict().get('respuestaCorrecta'),72 "subject" : doc.to_dict().get('subject'),73 "textoPregunta" : doc.to_dict().get('textoPregunta'),74 "unidad" : doc.to_dict().get('unidad'),75 }) 76 return sorted(data, key = lambda i: i['orderInt'])77 def getTE(self, params):78 te = []79 for question in self.questions:80 aux = {}81 for param in params:82 aux[param] = question[param]83 84 te.append(aux)85 86 return te87def getAnswers(userId, examId):88 doc_ref = db.collection(u'user').document(userId).collection(u'answers').document(examId)89 doc = doc_ref.get()90 return doc91def getExams(idExam = None):92 93 data = []94 if idExam is None:95 docs = db.collection('exam').order_by(u'prueba').stream()96 97 for doc in docs:98 data.append({99 "id" : doc.id,100 "Alternativa" : doc.to_dict().get('Alternativa'),101 "Asignatura" : doc.to_dict().get('Asignatura'),102 "Nivel" : doc.to_dict().get('Nivel'),103 "TipoEvaluacion" : doc.to_dict().get('TipoEvaluacion'),104 "level" : doc.to_dict().get('level'),105 "owner" : doc.to_dict().get('owner'),106 "prueba" : doc.to_dict().get('prueba'),107 "state" : doc.to_dict().get('state'),108 "subject" : doc.to_dict().get('subject'),109 "tipo" : doc.to_dict().get('tipo')110 })111 else:112 doc_ref = db.collection('exam').document(idExam)113 doc = doc_ref.get()114 115 data.append({116 "id" : doc.id,117 "Alternativa" : doc.to_dict().get('Alternativa'),118 "Asignatura" : doc.to_dict().get('Asignatura'),119 "Nivel" : doc.to_dict().get('Nivel'),120 "TipoEvaluacion" : doc.to_dict().get('TipoEvaluacion'),121 "level" : doc.to_dict().get('level'),122 "owner" : doc.to_dict().get('owner'),123 "prueba" : doc.to_dict().get('prueba'),124 "state" : doc.to_dict().get('state'),125 "subject" : doc.to_dict().get('subject'),126 "tipo" : doc.to_dict().get('tipo')127 })128 129 return data130def users(courseId):131 132 docs = db.collection(u'user').where(u'courseId', u'==', courseId).stream()133 data = [] 134 for doc in docs:135 data.append({136 "courseId" : doc.to_dict().get('courseId'),137 "id" : doc.id, 138 "name": doc.to_dict().get('name'),139 "surname": doc.to_dict().get('surname'), 140 "rut": doc.to_dict().get('rut'),141 "perfil": doc.to_dict().get('perfil'),142 }) 143 144 return data145def userAnswers(userId, examId):146 147 doc_ref = db.collection(u'user').document(userId).collection(u'answers').document(examId)148 respuestas = doc_ref.get().to_dict() 149 cont = 0150 if respuestas is None:151 cont = 0152 else:153 for respuesta in respuestas:154 print(respuesta)155 cont+= 1 156 return cont157def getPreguntas(examId):158 159 preguntas = []160 question_ref = db.collection('question').where(u"idEvaluacion", u'==', examId).stream()161 for question in question_ref:162 preguntas.append({163 "correcta" : question.to_dict().get('respuestaCorrecta'),164 "order" : question.to_dict().get('order'),165 })166 return preguntas167def getQuestions(examId):168 docs = db.collection(u'question').where(u'idEvaluacion', u'==', examId).stream()169 data = [] 170 171 for doc in docs:172 data.append({173 "id" : doc.id, 174 "RespuestaA" : doc.to_dict().get('RespuestaA'),175 "RespuestaB" : doc.to_dict().get('RespuestaB'),176 "RespuestaC" : doc.to_dict().get('RespuestaC'),177 "RespuestaD" : doc.to_dict().get('RespuestaD'),178 "code" : doc.to_dict().get('code'),179 "dominio" : doc.to_dict().get('dominio'),180 "eje" : doc.to_dict().get('eje'),181 "habilidad" : doc.to_dict().get('habilidad'),182 "idEvaluacion" : doc.to_dict().get('idEvaluacion'),183 "ie" : doc.to_dict().get('ie'),184 "level" : doc.to_dict().get('level'),185 "oa" : doc.to_dict().get('oa'),186 "order" : doc.to_dict().get('order'),187 "owner" : doc.to_dict().get('owner'),188 "respuestaCorrecta" : doc.to_dict().get('respuestaCorrecta'),189 "subject" : doc.to_dict().get('subject'),190 "textoPregunta" : doc.to_dict().get('textoPregunta'),191 "unidad" : doc.to_dict().get('unidad'),192 }) 193 return data194def getLogro(idAssigment):195 196 doc_ref = db.collection(u'assigments').document(idAssigment)197 doc = doc_ref.get()198 199 examId = doc.to_dict().get('examId')200 #preguntas = getPreguntas(examId)201 return examId202 #return preguntas203def te(examId, order, especificaciones):204 205 question_ref = db.collection('question').where(u"idEvaluacion", u'==', examId).where(u"order", u"==", order).stream()206 for question in question_ref:207 pregunta = db.collection('question').document(question.id)208 pregunta.set(especificaciones, merge=True)209 #pregunta.update(especificaciones)210def Pat(correct):211 pat ={0: 150,1: 159,2: 167,3: 173,4: 189,2125: 200,2136: 213,...

Full Screen

Full Screen

test_base_model.py

Source:test_base_model.py Github

copy

Full Screen

...38 self.assertEqual(type(i), self.value)39 def test_kwargs(self):40 """ testing basemodel with kwargs"""41 i = self.value()42 copy = i.to_dict()43 new = BaseModel(**copy)44 self.assertFalse(new is i)45 def test_kwargs_int(self):46 """ testing with kwargs again but with int kwargs"""47 i = self.value()48 copy = i.to_dict()49 copy.update({1: 2})50 with self.assertRaises(TypeError):51 new = BaseModel(**copy)52 def test_save(self):53 """ Testing save metthod"""54 i = self.value()55 i.save()56 key = self.name + "." + i.id57 with open('file.json', 'r') as f:58 j = json.load(f)59 self.assertEqual(j[key], i.to_dict())60 def test_str(self):61 """ testing the str method of themodel"""62 i = self.value()63 self.assertEqual(str(i), '[{}] ({}) {}'.format(self.name, i.id,64 i.__dict__))65 def test_todict(self):66 """ testing the to_dict method"""67 i = self.value()68 n = i.to_dict()69 self.assertEqual(i.to_dict(), n)70 # Tests if it's a dictionary71 self.assertIsInstance(self.value().to_dict(), dict)72 # Tests if to_dict contains accurate keys73 self.assertIn('id', self.value().to_dict())74 self.assertIn('created_at', self.value().to_dict())75 self.assertIn('updated_at', self.value().to_dict())76 # Tests if to_dict contains added attributes77 mdl = self.value()78 mdl.firstname = 'Celestine'79 mdl.lastname = 'Akpanoko'80 self.assertIn('firstname', mdl.to_dict())81 self.assertIn('lastname', mdl.to_dict())82 self.assertIn('firstname', self.value(firstname='Celestine').to_dict())83 self.assertIn('lastname', self.value(lastname='Akpanoko').to_dict())84 # Tests to_dict datetime attributes if they are strings85 self.assertIsInstance(self.value().to_dict()['created_at'], str)86 self.assertIsInstance(self.value().to_dict()['updated_at'], str)87 # Tests to_dict output88 datetime_now = datetime.today()89 mdl = self.value()90 mdl.id = '012345'91 mdl.created_at = mdl.updated_at = datetime_now92 to_dict = {93 'id': '012345',94 '__class__': mdl.__class__.__name__,95 'created_at': datetime_now.isoformat(),96 'updated_at': datetime_now.isoformat()97 }98 self.assertDictEqual(mdl.to_dict(), to_dict)99 if os.getenv('HBNB_TYPE_STORAGE') != 'db':100 self.assertDictEqual(101 self.value(id='u-b34', age=13).to_dict(),102 {103 '__class__': mdl.__class__.__name__,104 'id': 'u-b34',105 'age': 13106 }107 )108 self.assertDictEqual(109 self.value(id='u-b34', age=None).to_dict(),110 {111 '__class__': mdl.__class__.__name__,112 'id': 'u-b34',113 'age': None114 }115 )116 # Tests to_dict output contradiction117 mdl_d = self.value()118 self.assertIn('__class__', self.value().to_dict())119 self.assertNotIn('__class__', self.value().__dict__)120 self.assertNotEqual(mdl_d.to_dict(), mdl_d.__dict__)121 self.assertNotEqual(122 mdl_d.to_dict()['__class__'],123 mdl_d.__class__124 )125 # Tests to_dict with arg126 with self.assertRaises(TypeError):127 self.value().to_dict(None)128 with self.assertRaises(TypeError):129 self.value().to_dict(self.value())130 with self.assertRaises(TypeError):131 self.value().to_dict(45)132 self.assertNotIn('_sa_instance_state', n)133 def test_kwargs_none(self):134 """ testing kwargs again with none"""135 n = {None: None}136 with self.assertRaises(TypeError):137 new = self.value(**n)138 def test_kwargs_one(self):139 """ testing kwargs with one arg"""140 n = {'name': 'test'}141 new = self.value(**n)142 self.assertEqual(new.name, n['name'])143 def test_id(self):144 """ testing id attr of the model"""145 new = self.value()146 self.assertEqual(type(new.id), str)147 def test_created_at(self):148 """ testing created at attr"""149 new = self.value()150 self.assertEqual(type(new.created_at), datetime)151 def test_updated_at(self):152 """ testing updated at attr"""153 new = self.value()154 self.assertEqual(type(new.updated_at), datetime)155 n = new.to_dict()156 new = BaseModel(**n)...

Full Screen

Full Screen

test_params.py

Source:test_params.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from autojsdoc.parser.jsdoc import ParamDoc3"Lorem ipsum dolor sit amet, consectetur adipiscing elit."4def test_basic():5 d = ParamDoc("Lorem ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()6 assert d == {7 'name': 'Lorem',8 'type': '',9 'optional': False,10 'default': None,11 'doc': 'ipsum dolor sit amet, consectetur adipiscing elit.',12 }13 d = ParamDoc("{Lorem} ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()14 assert d == {15 'name': 'ipsum',16 'type': 'Lorem',17 'optional': False,18 'default': None,19 'doc': 'dolor sit amet, consectetur adipiscing elit.',20 }21def test_optional():22 d = ParamDoc("[Lorem] ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()23 assert d == {24 'name': 'Lorem',25 'type': '',26 'optional': True,27 'default': None,28 'doc': 'ipsum dolor sit amet, consectetur adipiscing elit.',29 }30 d = ParamDoc("[Lorem=42] ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()31 assert d == {32 'name': 'Lorem',33 'type': '',34 'optional': True,35 'default': "42",36 'doc': 'ipsum dolor sit amet, consectetur adipiscing elit.',37 }38 d = ParamDoc("{Lorem} [ipsum] dolor sit amet, consectetur adipiscing elit.").to_dict()39 assert d == {40 'name': 'ipsum',41 'type': 'Lorem',42 'optional': True,43 'default': None,44 'doc': 'dolor sit amet, consectetur adipiscing elit.',45 }46 d = ParamDoc("{Lorem} [ipsum=42] dolor sit amet, consectetur adipiscing elit.").to_dict()47 assert d == {48 'name': 'ipsum',49 'type': 'Lorem',50 'optional': True,51 'default': '42',52 'doc': 'dolor sit amet, consectetur adipiscing elit.',53 }54def test_returns():55 d = ParamDoc("{} ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()56 assert d == {57 'name': '',58 'type': '',59 'optional': False,60 'default': None,61 'doc': 'ipsum dolor sit amet, consectetur adipiscing elit.',62 }63 d = ParamDoc("{Lorem} ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()64 assert d == {65 'name': '',66 'type': 'Lorem',67 'optional': False,68 'default': None,69 'doc': 'ipsum dolor sit amet, consectetur adipiscing elit.',70 }71def test_odd():72 d = ParamDoc("{jQuery} [$target] the node where content will be prepended").to_dict()73 assert d == {74 'name': '$target',75 'type': 'jQuery',76 'optional': True,77 'default': None,78 'doc': 'the node where content will be prepended',79 }80 d = ParamDoc("""{htmlString} [content] DOM element,81 array of elements, HTML string or jQuery object to prepend to $target""").to_dict()82 assert d == {83 'name': 'content',84 'type': 'htmlString',85 'optional': True,86 'default': None,87 'doc': "DOM element,\n array of elements, HTML string or jQuery object to prepend to $target",88 }89 d = ParamDoc("{Boolean} [options.in_DOM] true if $target is in the DOM").to_dict()90 assert d == {91 'name': 'options.in_DOM',92 'type': 'Boolean',93 'optional': True,94 'default': None,95 'doc': 'true if $target is in the DOM',96 }97 d = ParamDoc("Lorem\n ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()98 assert d['doc'] == 'ipsum dolor sit amet, consectetur adipiscing elit.'99 d = ParamDoc("Lorem - ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()100 assert d['doc'] == 'ipsum dolor sit amet, consectetur adipiscing elit.'101 d = ParamDoc("Lorem : ipsum dolor sit amet, consectetur adipiscing elit.").to_dict()...

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