How to use populate method in hypothesis

Best Python code snippet using hypothesis

cropRepository.ts

Source:cropRepository.ts Github

copy

Full Screen

...23 sort,24 populate25 }: any): Promise<any> {26 return Crop.find(query ?? {})27 .populate(populate ?? [])28 .limit(limit ?? 0)29 .skip(skip ?? 0)30 .sort(sort ?? {})31 }32 /**33 * @function findCropsSample34 * Get crops sample.35 * @param object query36 */37 public static async findCropsSample(query) {38 const crops = await Crop.find(query).lean()39 return crops40 }41 public static async findOneSample(query) {42 return Crop.findOne(query).lean()43 }44 /**45 *46 * @param identifier47 */48 public static async findAllCropsByCompanies(identifier: string) {49 const cropsInstance = await Crop.find({50 cancelled: false,51 'members.identifier': identifier52 })53 .populate('lots.data')54 .populate('cropType')55 .populate('unitType')56 .populate({57 path: 'company',58 populate: [59 { path: 'files' },60 { path: 'contacts.user' },61 { path: 'country' }62 ]63 })64 .populate({65 path: 'pending',66 populate: [67 { path: 'collaborators' },68 { path: 'type' },69 { path: 'typeAgreement' },70 { path: 'lots', select: '-area -__v' },71 { path: 'files' },72 {73 path: 'supplies',74 populate: [{ path: 'typeId' }]75 },76 {77 path: 'storages',78 populate: [{ path: 'storageType' }]79 }80 ]81 })82 .populate({83 path: 'toMake',84 populate: [85 { path: 'collaborators' },86 { path: 'type' },87 { path: 'typeAgreement' },88 { path: 'lots', select: '-area -__v' },89 { path: 'files' },90 {91 path: 'supplies',92 populate: [{ path: 'typeId' }]93 },94 {95 path: 'storages',96 populate: [{ path: 'storageType' }]97 }98 ]99 })100 .populate({101 path: 'done',102 populate: [103 { path: 'collaborators' },104 { path: 'type' },105 { path: 'typeAgreement' },106 { path: 'lots', select: '-area -__v' },107 { path: 'files' },108 {109 path: 'achievements',110 populate: [111 { path: 'lots' },112 { path: 'files' },113 { path: 'supplies', populate: [{ path: 'typeId' }] }114 ]115 },116 {117 path: 'supplies',118 populate: [{ path: 'typeId' }]119 },120 {121 path: 'storages',122 populate: [{ path: 'storageType' }]123 },124 { path: 'lotsMade' }125 ]126 })127 .populate({128 path: 'finished',129 populate: [130 { path: 'collaborators' },131 { path: 'type' },132 { path: 'typeAgreement' },133 { path: 'lots', select: '-area -__v' },134 { path: 'files' },135 {136 path: 'supplies',137 populate: [{ path: 'typeId' }]138 },139 {140 path: 'storages',141 populate: [{ path: 'storageType' }]142 },143 {144 path: 'achievements',145 populate: [146 { path: 'lots' },147 { path: 'files' },148 { path: 'supplies', populate: [{ path: 'typeId' }] }149 ]150 }151 ]152 })153 .populate('members.user')154 .lean()155 return cropsInstance.length156 ? cropsInstance.map((crop) => joinActivitiesByCrop(crop))157 : null158 }159 /**160 * Get One crop and json converter.161 *162 * @param id163 */164 public static async getCropWithActivities(id: string) {165 const cropInstance = await Crop.findById(id)166 .populate({167 path: 'lots.data',168 populate: [{ path: 'envImpactIndex', select: 'eiq' }]169 })170 .populate('cropType')171 .populate('unitType')172 .populate('envImpactIndex', 'eiq')173 .populate('badges.badge')174 .populate({175 path: 'pending',176 populate: [177 { path: 'collaborators' },178 { path: 'envImpactIndex', select: 'eiq' },179 { path: 'unitType' },180 { path: 'type' },181 { path: 'typeAgreement' },182 { path: 'files' },183 { path: 'lots', select: '-area -__v -geometryData' },184 {185 path: 'supplies',186 populate: [{ path: 'typeId' }]187 },188 {189 path: 'storages',190 populate: [{ path: 'storageType' }]191 }192 ]193 })194 .populate({195 path: 'toMake',196 populate: [197 { path: 'collaborators' },198 { path: 'envImpactIndex', select: 'eiq' },199 { path: 'unitType' },200 { path: 'type' },201 { path: 'typeAgreement' },202 { path: 'lots', select: '-area -__v -geometryData' },203 { path: 'files' },204 {205 path: 'supplies',206 populate: [{ path: 'typeId' }]207 },208 {209 path: 'storages',210 populate: [{ path: 'storageType' }]211 }212 ]213 })214 .populate({215 path: 'done',216 populate: [217 { path: 'envImpactIndex', select: 'eiq' },218 { path: 'collaborators' },219 { path: 'unitType' },220 { path: 'type' },221 { path: 'typeAgreement' },222 {223 path: 'lots',224 select: '-area -__v -geometryData',225 populate: [{ path: 'envImpactIndex', select: 'eiq' }]226 },227 { path: 'files' },228 {229 path: 'achievements',230 populate: [231 {232 path: 'lots',233 populate: [{ path: 'envImpactIndex', select: 'eiq' }]234 },235 { path: 'envImpactIndex', select: 'eiq' },236 { path: 'files' },237 { path: 'supplies.supply', populate: [{ path: 'typeId' }] },238 { path: 'supplies.typeId' }239 ]240 },241 { path: 'supplies.supply', populate: [{ path: 'typeId' }] },242 { path: 'supplies.typeId' },243 {244 path: 'storages',245 populate: [{ path: 'storageType' }]246 },247 { path: 'lotsMade' }248 ]249 })250 .populate({251 path: 'finished',252 populate: [253 { path: 'envImpactIndex', select: 'eiq' },254 { path: 'collaborators' },255 { path: 'unitType' },256 { path: 'type' },257 { path: 'typeAgreement' },258 {259 path: 'lots',260 select: '-area -__v -geometryData',261 populate: [{ path: 'envImpactIndex', select: 'eiq' }]262 },263 { path: 'files' },264 { path: 'supplies.supply', populate: [{ path: 'typeId' }] },265 { path: 'supplies.typeId' },266 {267 path: 'storages',268 populate: [{ path: 'storageType' }]269 },270 {271 path: 'achievements',272 populate: [273 {274 path: 'lots',275 populate: [{ path: 'envImpactIndex', select: 'eiq' }]276 },277 { path: 'envImpactIndex', select: 'eiq' },278 { path: 'files' },279 { path: 'supplies.supply', populate: [{ path: 'typeId' }] },280 { path: 'supplies.typeId' }281 ]282 }283 ]284 })285 .populate('members.user')286 .lean({ virtuals: true })287 return cropInstance ? joinActivitiesByCrop(cropInstance) : null288 }289 /**290 * Get All crops by identifier and type.291 *292 * @param string id293 */294 public static async findAllCropsByCompanyAndCropType({ cropType, company }) {295 const cropsInstance = await Crop.find({296 cancelled: false,297 cropType,298 company299 })300 .populate('unitType')301 .lean()302 return cropsInstance.length ? cropsInstance : null303 }304 /**305 * Get All crops by identifier and type.306 *307 * @param string id308 */309 public static async findAllCropType({ id }) {310 const cropTypeInstance = await CropType.find({ id }).populate('name').lean()311 return cropTypeInstance.length ? cropTypeInstance : null312 }313 public static async findCropsWithLotsPopulateData(query) {314 const crops = await Crop.find(query).populate('lots.data')315 return crops316 }317 public static async findAllEvidencesByCropId(cropId: string) {318 const cropsInstance = await Crop.findById(cropId)319 .populate({320 path: 'done',321 populate: [322 { path: 'files' },323 { path: 'satelliteImages' },324 {325 path: 'achievements',326 populate: [{ path: 'files' }]327 }328 ]329 })330 .populate('members.user')331 .populate({332 path: 'company',333 populate: [334 { path: 'files' },335 { path: 'contacts.user' },336 { path: 'country' }337 ]338 })339 .populate({340 path: 'finished',341 populate: [342 { path: 'files' },343 { path: 'satelliteImages' },344 {345 path: 'achievements',346 populate: [{ path: 'files' }]347 }348 ]349 })350 .lean({ virtuals: true })351 return cropsInstance ? listEvidencesCrop(cropsInstance) : null352 }353 /**354 * Get crops.355 *356 * @param object pipeline357 */358 public static async findCrops(pipeline: any) {359 const cropsInstance = await Crop.aggregate(pipeline).allowDiskUse(true)360 return cropsInstance.length ? cropsInstance : null361 }362 /**363 *364 * @param query365 * @param dataToUpdate366 *367 * @returns368 */369 public static async updateOneCrop(370 query: any,371 dataToUpdate: any372 ): Promise<any> {373 return Crop.updateOne(query, dataToUpdate)374 }375 /**376 *377 * @param type378 */379 public static async findCropsFilterActivityForBilling(query, type) {380 const cropsInstance = await this.getCropWithPopulates(query, 'find')381 return !!cropsInstance.length382 ? joinActivitiesFilterTypeWithCrop(cropsInstance, type)383 : null384 }385 /**386 *387 * @param query388 * @returns389 */390 private static async getCropWithPopulates(391 query,392 method: string,393 isVirtuals?: boolean394 ) {395 const queryCrops = Crop[method](query)396 .populate('lots.data')397 .populate('cropType')398 .populate('unitType')399 .populate({400 path: 'company',401 populate: [402 { path: 'files' },403 { path: 'contacts.user' },404 { path: 'country' }405 ]406 })407 .populate({408 path: 'pending',409 populate: [410 { path: 'collaborators' },411 { path: 'type' },412 { path: 'typeAgreement' },413 { path: 'lots', select: '-area -__v' },414 { path: 'files' },415 {416 path: 'supplies',417 populate: [{ path: 'typeId' }]418 },419 {420 path: 'storages',421 populate: [{ path: 'storageType' }]422 }423 ]424 })425 .populate({426 path: 'toMake',427 populate: [428 { path: 'collaborators' },429 { path: 'type' },430 { path: 'typeAgreement' },431 { path: 'lots', select: '-area -__v' },432 { path: 'files' },433 {434 path: 'supplies',435 populate: [{ path: 'typeId' }]436 },437 {438 path: 'storages',439 populate: [{ path: 'storageType' }]440 }441 ]442 })443 .populate({444 path: 'done',445 populate: [446 { path: 'collaborators' },447 { path: 'type' },448 { path: 'typeAgreement' },449 { path: 'lots', select: '-area -__v' },450 { path: 'files' },451 {452 path: 'achievements',453 populate: [454 { path: 'lots' },455 { path: 'files' },456 { path: 'supplies', populate: [{ path: 'typeId' }] }457 ]458 },459 {460 path: 'supplies',461 populate: [{ path: 'typeId' }]462 },463 {464 path: 'storages',465 populate: [{ path: 'storageType' }]466 },467 { path: 'lotsMade' }468 ]469 })470 .populate({471 path: 'finished',472 populate: [473 { path: 'collaborators' },474 { path: 'type' },475 { path: 'typeAgreement' },476 { path: 'lots', select: '-area -__v' },477 { path: 'files' },478 {479 path: 'supplies',480 populate: [{ path: 'typeId' }]481 },482 {483 path: 'storages',484 populate: [{ path: 'storageType' }]485 },486 {487 path: 'achievements',488 populate: [489 { path: 'lots' },490 { path: 'files' },491 { path: 'supplies', populate: [{ path: 'typeId' }] }492 ]493 }494 ]495 })496 .populate('members.user')497 if (isVirtuals) {498 return queryCrops.lean({ virtuals: true })499 }500 return queryCrops.lean()501 }...

Full Screen

Full Screen

Query.js

Source:Query.js Github

copy

Full Screen

...8 // check if user loggedIn ?9 if (!userId) throw new Error("User not logged in please login !");10 // if (userId !== args.id) throw new Error("Not Authorized");11 return User.findById(userId)12 .populate({13 path: "subcontracts",14 options: { sort: { createdAt: "asc" } },15 populate: { path: "subcontractCreatorId" },16 })17 .populate({18 path: "hirecontracts",19 options: { sort: { createdAt: "asc" } },20 populate: { path: "hirecontractCreatorId" },21 })22 .populate({23 path: "subcontracts",24 populate: { path: "hirecontractWorkId" },25 })26 .populate({27 path: "hirecontracts",28 populate: { path: "subcontractAcceptHirecontractId" },29 });30 },31 users: (parent, args, context, info) =>32 User.find({})33 .populate({34 path: "subcontracts",35 options: { sort: { createdAt: "asc" } },36 populate: { path: "subcontractCreatorId" },37 })38 .populate({39 path: "hirecontracts",40 options: { sort: { createdAt: "asc" } },41 populate: { path: "hirecontractCreatorId" },42 }),43 // Subcontract44 subcontract: (parent, args, context, info) =>45 Subcontract.findById(args.id)46 .populate({47 path: "subcontractCreatorId",48 populate: { path: "subcontracts" },49 })50 .populate({51 path: "hirecontractWorkId",52 populate: { path: "hirecontracts" },53 }),54 subcontracthasassign: (parent, args, context, info) =>55 Subcontract.find({ subcontractCreatorId: ObjectId(args.id) })56 .populate({57 path: "subcontractCreatorId",58 populate: { path: "subcontracts" },59 })60 .populate({61 path: "hirecontractWorkId",62 populate: { path: "subcontracts" },63 })64 .sort({ createdAt: "asc" }),65 subcontracts: (parent, args, context, info) =>66 Subcontract.find({})67 .populate({68 path: "subcontractCreatorId",69 populate: { path: "subcontracts" },70 })71 .sort({ createdAt: "asc" })72 .populate({73 path: "hirecontractWorkId",74 populate: { path: "hirecontracts" },75 }),76 subcontractswaiting: (parent, args, context, info) =>77 Subcontract.find({ status: "WAITING" })78 .populate({79 path: "subcontractCreatorId",80 populate: { path: "subcontracts" },81 })82 .sort({ createdAt: "asc" })83 .populate({84 path: "hirecontractWorkId",85 populate: { path: "hirecontracts" },86 }),87 subcontractsapprove: (parent, args, context, info) =>88 Subcontract.find({ status: "ยืนยันแล้ว" })89 .populate({90 path: "subcontractCreatorId",91 populate: { path: "subcontracts" },92 })93 .sort({ createdAt: "asc" })94 .populate({95 path: "hirecontractWorkId",96 populate: { path: "hirecontracts" },97 }),98 subcontractsdenied: (parent, args, context, info) =>99 Subcontract.find({ status: "ปฎิเสธ" })100 .populate({101 path: "subcontractCreatorId",102 populate: { path: "subcontracts" },103 })104 .sort({ createdAt: "asc" })105 .populate({106 path: "hirecontractWorkId",107 populate: { path: "hirecontracts" },108 }),109 subcontractspendingcancel: (parent, args, context, info) =>110 Subcontract.find({ status: "กำลังรอการตอบรับจากผู้ประสานงาน" })111 .populate({112 path: "subcontractCreatorId",113 populate: { path: "subcontracts" },114 })115 .sort({ createdAt: "asc" })116 .populate({117 path: "hirecontractWorkId",118 populate: { path: "hirecontracts" },119 }),120 adminapprovesubcontractspendingcancel: (parent, args, context, info) =>121 Subcontract.find({ status: "ผู้ประสานงานยินยอมการยกเลิกเรียบร้อยแล้ว" })122 .populate({123 path: "subcontractCreatorId",124 populate: { path: "subcontracts" },125 })126 .sort({ createdAt: "asc" })127 .populate({128 path: "hirecontractWorkId",129 populate: { path: "hirecontracts" },130 }),131 subcontractswebdevelopment: (parent, args, context, info) =>132 Subcontract.find({133 $and: [134 { status: "ตรวจสอบแล้ว" },135 { natureofwork: { $regex: "web development" } },136 ],137 })138 .populate({139 path: "subcontractCreatorId",140 populate: { path: "subcontracts" },141 })142 .sort({ createdAt: "asc" })143 .populate({144 path: "hirecontractWorkId",145 populate: { path: "hirecontracts" },146 }),147 subcontractswordpress: (parent, args, context, info) =>148 Subcontract.find({149 $and: [150 { status: "ตรวจสอบแล้ว" },151 { natureofwork: { $regex: "wordpress" } },152 ],153 })154 .populate({155 path: "subcontractCreatorId",156 populate: { path: "subcontracts" },157 })158 .sort({ createdAt: "asc" }),159 // Hirecontract160 hirecontract: (parent, args, context, info) =>161 Hirecontract.findById(args.id)162 .populate({163 path: "hirecontractCreatorId",164 populate: { path: "hirecontracts" },165 })166 .populate({167 path: "subcontractAcceptHirecontractId",168 populate: { path: "subcontracts" },169 }),170 hirecontracts: (parent, args, context, info) =>171 Hirecontract.find({})172 .populate({173 path: "hirecontractCreatorId",174 populate: { path: "hirecontracts" },175 })176 .populate({177 path: "subcontractAcceptHirecontractId",178 populate: { path: "subcontracts" },179 })180 .populate({181 path:"subcontractCreatorId",182 populate:{path:"users"}183 })184 .sort({ createdAt: "desc" }),185 hirecontractswaiting: (parent, args, context, info) =>186 Hirecontract.find({ status: "WAITING" })187 .populate({188 path: "hirecontractCreatorId",189 populate: { path: "hirecontracts" },190 })191 .populate({192 path: "subcontractAcceptHirecontractId",193 populate: { path: "subcontracts" },194 }),195 hirecontractswaitingassign: (parent, args, context, info) =>196 Hirecontract.find({ status: "กำลังรอการตอบรับจากผู้รับเหมาช่วง" }).populate(197 {198 path: "hirecontractCreatorId",199 populate: { path: "subcontracts" },200 }201 ),202 hirecontractsapprove: (parent, args, context, info) =>203 Hirecontract.find({ status: "APPROVE" })204 .populate({205 path: "hirecontractCreatorId",206 populate: { path: "hirecontracts" },207 })208 .populate({209 path: "subcontractAcceptHirecontractId",210 populate: { path: "subcontracts" },211 }),212 hirecontractsdenied: (parent, args, context, info) =>213 Hirecontract.find({ status: "DENIED" })214 .populate({215 path: "hirecontractCreatorId",216 populate: { path: "hirecontracts" },217 })218 .populate({219 path: "subcontractAcceptHirecontractId",220 populate: { path: "subcontracts" },221 }),222 hirecontractspendingcancel: (parent, args, context, info) =>223 Hirecontract.find({ status: "HIRECONTRACT-PENDINGCANCEL" })224 .populate({225 path: "hirecontractCreatorId",226 populate: { path: "hirecontracts" },227 })228 .populate({229 path: "subcontractAcceptHirecontractId",230 populate: { path: "subcontracts" },231 }),232 hirecontractspendingcancel: (parent, args, context, info) =>233 Hirecontract.find({ status: "SUBCONTRACT-PENDINGCANCEL" })234 .populate({235 path: "hirecontractCreatorId",236 populate: { path: "hirecontracts" },237 })238 .populate({239 path: "subcontractAcceptHirecontractId",240 populate: { path: "subcontracts" },241 }),242 adminapprovehirecontractscancel: (parent, args, context, info) =>243 Hirecontract.find({ status: "CANCEL" })244 .populate({245 path: "hirecontractCreatorId",246 populate: { path: "hirecontracts" },247 })248 .populate({249 path: "subcontractAcceptHirecontractId",250 populate: { path: "subcontracts" },251 }),...

Full Screen

Full Screen

res_partner.py

Source:res_partner.py Github

copy

Full Screen

...106 [False, self.env.ref('base.main_company').id] + company_ids,107 [1, 1] + [1/(len(company_ids) or 1)]*len(company_ids))),108 ('parent_id', populate.constant(False)), # will be setted in _populate override109 ]110 def _populate(self, size):111 records = super()._populate(size)112 # set parent_ids113 self._populate_set_companies(records)114 return records115 def _populate_set_companies(self, records):116 _logger.info('Setting companies')117 r_company = populate.Random('res.partner+company_has_partners') # 50% change to have partners118 companies = records.filtered(lambda p: p.is_company and r_company.getrandbits(1))119 partners = records - companies120 r_partner = populate.Random('res.partner+partner_has_company')121 r_company_pick = populate.Random('res.partner+partner_company_pick=')122 companies_partners = collections.defaultdict(lambda: self.env['res.partner'])123 for count, partner in enumerate(partners):124 if bool(r_partner.getrandbits(1)): # 50% change to have a company125 companies_partners[r_company_pick.choice(companies)] |= partner...

Full Screen

Full Screen

lunch.py

Source:lunch.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Part of Odoo. See LICENSE file for full copyright and licensing details.3import logging4from dateutil.relativedelta import relativedelta5from itertools import groupby6from odoo import models7from odoo.tools import populate8_logger = logging.getLogger(__name__)9class LunchProductCategory(models.Model):10 _inherit = 'lunch.product.category'11 _populate_sizes = {'small': 5, 'medium': 150, 'large': 400}12 _populate_dependencies = ['res.company']13 def _populate_factories(self):14 # TODO topping_ids_{1,2,3}, toppping_label_{1,2,3}, topping_quantity{1,2,3}15 company_ids = self.env.registry.populated_models['res.company']16 return [17 ('name', populate.constant('lunch_product_category_{counter}')),18 ('company_id', populate.iterate(19 [False, self.env.ref('base.main_company').id] + company_ids,20 [1, 1] + [2/(len(company_ids) or 1)]*len(company_ids))),21 ]22class LunchProduct(models.Model):23 _inherit = 'lunch.product'24 _populate_sizes = {'small': 10, 'medium': 150, 'large': 10000}25 _populate_dependencies = ['lunch.product.category', 'lunch.supplier']26 def _populate_factories(self):27 category_ids = self.env.registry.populated_models['lunch.product.category']28 category_records = self.env['lunch.product.category'].browse(category_ids)29 category_by_company = {k: list(v) for k, v in groupby(category_records, key=lambda rec: rec['company_id'].id)}30 supplier_ids = self.env.registry.populated_models['lunch.supplier']31 company_by_supplier = {rec.id: rec.company_id.id for rec in self.env['lunch.supplier'].browse(supplier_ids)}32 def get_category(random=None, values=None, **kwargs):33 company_id = company_by_supplier[values['supplier_id']]34 return random.choice(category_by_company[company_id]).id35 return [36 ('active', populate.iterate([True, False], [0.9, 0.1])),37 ('name', populate.constant('lunch_product_{counter}')),38 ('price', populate.randfloat(0.1, 50)),39 ('supplier_id', populate.randomize(supplier_ids)),40 ('category_id', populate.compute(get_category)),41 ]42class LunchLocation(models.Model):43 _inherit = 'lunch.location'44 _populate_sizes = {'small': 3, 'medium': 50, 'large': 500}45 _populate_dependencies = ['res.company']46 def _populate_factories(self):47 company_ids = self.env.registry.populated_models['res.company']48 return [49 ('name', populate.constant('lunch_location_{counter}')),50 ('address', populate.constant('lunch_address_location_{counter}')),51 ('company_id', populate.randomize(company_ids))52 ]53class LunchSupplier(models.Model):54 _inherit = 'lunch.supplier'55 _populate_sizes = {'small': 3, 'medium': 50, 'large': 1500}56 _populate_dependencies = ['lunch.location', 'res.partner', 'res.users']57 def _populate_factories(self):58 location_ids = self.env.registry.populated_models['lunch.location']59 partner_ids = self.env.registry.populated_models['res.partner']60 user_ids = self.env.registry.populated_models['res.users']61 def get_location_ids(random=None, **kwargs):62 nb_locations = random.randint(0, len(location_ids))63 return [(6, 0, random.choices(location_ids, k=nb_locations))]64 return [65 ('active', populate.cartesian([True, False])),66 ('send_by', populate.cartesian(['phone', 'mail'])),67 ('delivery', populate.cartesian(['delivery', 'no_delivery'])),68 ('mon', populate.iterate([True, False], [0.9, 0.1])),69 ('tue', populate.iterate([True, False], [0.9, 0.1])),70 ('wed', populate.iterate([True, False], [0.9, 0.1])),71 ('thu', populate.iterate([True, False], [0.9, 0.1])),72 ('fri', populate.iterate([True, False], [0.9, 0.1])),73 ('sat', populate.iterate([False, True], [0.9, 0.1])),74 ('sun', populate.iterate([False, True], [0.9, 0.1])),75 ('available_location_ids', populate.iterate(76 [[], [(6, 0, location_ids)]],77 then=populate.compute(get_location_ids))),78 ('partner_id', populate.randomize(partner_ids)),79 ('responsible_id', populate.randomize(user_ids)),80 ('moment', populate.iterate(['am', 'pm'])),81 ('automatic_email_time', populate.randfloat(0, 12)),82 ]83class LunchOrder(models.Model):84 _inherit = 'lunch.order'85 _populate_sizes = {'small': 20, 'medium': 3000, 'large': 15000}86 _populate_dependencies = ['lunch.product', 'res.users', 'res.company']87 def _populate_factories(self):88 # TODO topping_ids_{1,2,3}, topping_label_{1,3}, topping_quantity_{1,3}89 user_ids = self.env.registry.populated_models['res.users']90 product_ids = self.env.registry.populated_models['lunch.product']91 company_ids = self.env.registry.populated_models['res.company']92 return [93 ('active', populate.cartesian([True, False])),94 ('state', populate.cartesian(['new', 'confirmed', 'ordered', 'cancelled'])),95 ('product_id', populate.randomize(product_ids)),96 ('user_id', populate.randomize(user_ids)),97 ('note', populate.constant('lunch_note_{counter}')),98 ('company_id', populate.randomize(company_ids)),99 ('quantity', populate.randint(0, 10)),100 ]101class LunchAlert(models.Model):102 _inherit = 'lunch.alert'103 _populate_sizes = {'small': 10, 'medium': 40, 'large': 150}104 _populate_dependencies = ['lunch.location']105 def _populate_factories(self):106 location_ids = self.env.registry.populated_models['lunch.location']107 def get_location_ids(random=None, **kwargs):108 nb_max = len(location_ids)109 start = random.randint(0, nb_max)110 end = random.randint(start, nb_max)111 return location_ids[start:end]112 return [113 ('active', populate.cartesian([True, False])),114 ('recipients', populate.cartesian(['everyone', 'last_week', 'last_month', 'last_year'])),115 ('mode', populate.iterate(['alert', 'chat'])),116 ('mon', populate.iterate([True, False], [0.9, 0.1])),117 ('tue', populate.iterate([True, False], [0.9, 0.1])),118 ('wed', populate.iterate([True, False], [0.9, 0.1])),119 ('thu', populate.iterate([True, False], [0.9, 0.1])),120 ('fri', populate.iterate([True, False], [0.9, 0.1])),121 ('sat', populate.iterate([False, True], [0.9, 0.1])),122 ('sun', populate.iterate([False, True], [0.9, 0.1])),123 ('name', populate.constant('alert_{counter}')),124 ('message', populate.constant('<strong>alert message {counter}</strong>')),125 ('notification_time', populate.randfloat(0, 12)),126 ('notification_moment', populate.iterate(['am', 'pm'])),127 ('until', populate.randdatetime(relative_before=relativedelta(years=-2), relative_after=relativedelta(years=2))),128 ('location_ids', populate.compute(get_location_ids))...

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