def createUser(): username = helper_functions.random_string(10) username += "@" username += helper_functions.random_string(5) username += "." username += helper_functions.random_string(3) password = helper_functions.random_string(10) return username, password
def validate_post_data(post_data): permalink = random_string(12) post_data['title'] = cgi.escape(post_data['title']) post_data['preview'] = cgi.escape(post_data['preview'], quote=True) post_data['body'] = cgi.escape(post_data['body'], quote=True) post_data['date'] = datetime.utcnow() post_data['permalink'] = permalink return post_data
def createApp(): name = helper_functions.random_string(10) tar = helper_functions.random_string(1000) return name, tar
####################################### # Retrieve the user's data with no apps ####################################### ret = server.get_user_data(user[0], super_secret) if user[0] not in ret or user[1] not in ret: err(helper_functions.lineno(), ret) ################# # Get empty token ################# ret = server.get_token(user[0], super_secret) if "token:notSet" not in ret: err(helper_functions.lineno(), ret) ################# # Change password ################# newpw = helper_functions.random_string(10) ret = server.change_password(user[0], newpw, super_secret) if ret != "true": err(helper_functions.lineno(), ret) ####################################### # Retrieve the user's data with new pw ####################################### ret = server.get_user_data(user[0], super_secret) if user[0] not in ret or newpw not in ret: err(helper_functions.lineno(), ret) ###################### # Change password back ###################### ret = server.change_password(user[0], user[1], super_secret) if ret != "true": err(helper_functions.lineno(), ret)
post = db.posts comment = [ ] db.posts.update({'_id':{'$exists':True}},{'$set':{'comment':comment}},multi=True) #db.posts.update({"_id" : p['_id']},{$set : { "comment": [{"username":"******","body":"beautiful!"}]}}) comment1 = { "id" : random_string(18), "name" : "user", "email" : "*****@*****.**", "body" : "holyshit7" } #postClass.collection.insert_one({"comment":comment}) print comment1 #postClass.posts.update({"_id" : ObjectId("5633862ce13823b09ddb752f")},{$set : { "comment": comment}}) #print postClass.get_post_by_permalink("8LVYQL3ZHWSQ")['data']['title'] #print id #postClass.collection.update({"_id" : id} ,{"$push": {"comment":comment1}})
def createRandomList(number_of_columns, column_name_len): columns = [] for ii in range(0, number_of_columns): columns += [hf.random_string(column_name_len)] return columns