How to use _create_line method in autotest

Best Python code snippet using autotest_python

configframe.py

Source:configframe.py Github

copy

Full Screen

...28 self.controls = {}29 self.comb_keys = []30 self.entry_keys = []31 32 def _create_line(parent, name):33 f = Frame(parent)34 f.pack(fill='x')35 Label(f, text=name, font=('΢ÈíÑźÚ', 10)).pack(side='left')36 return f37 38 def _entry(parent, name, **kkargs):39 e = Entry(parent, state='readonly', font=('΢ÈíÑźÚ', 10), justify='center', fg='black', **kkargs)40 e.pack(side='left', padx=3, pady=3)41 self.controls[name] = e42 self.entry_keys.append(name)43 44 def _combo(parent, name, value=('¿ªÆô', '¹Ø±Õ'), **kkargs):45 c = ttk.Combobox(parent, value=value, state='disabled', justify='center', **kkargs)46 c.pack(side='left', padx=3, pady=3)47 self.controls[name] = c48 self.comb_keys.append(name)49 50 #¾ßÌåÅäÖÃÇø51 f2 = Frame(self)52 f2.pack(fill='x')53 54 left = Frame(f2, width=190, height=CONFIG_HEIGHT)55 left.pack_propagate(0)56 left.pack(side='left')5758 right = Frame(f2, width=190, height=CONFIG_HEIGHT)59 right.pack_propagate(0)60 right.pack(side='right')6162 f = _create_line(left, '·þÎñÆ÷ID')63 _entry(f, 'srvid')64 f = _create_line(left, '¿ª·þʱ¼ä')65 _entry(f, 'open_time')66 f = _create_line(left, '²âÊÔģʽ')67 _combo(f, 'testsrv')68 if opt in GAME_CONFIG:69 f = _create_line(left, 'Ö÷¿Øip')70 _entry(f, 'proxyhost')71 f = _create_line(left, '¾º¼¼³¡Ö÷¿Øip')72 _entry(f, 'grouphost')73 elif opt in BATTLE_CONFIG:74 f = _create_line(left, 'Ö÷¿Øip')75 _entry(f, 'proxyhost')76 f = _create_line(left, 'Õ½¶··þÀàÐÍ')77 _combo(f, 'combatserver', list(COMBATSERVER_TYPE_NAME.keys()))78 f = _create_line(left, '¾º¼¼³¡Ö÷¿Øip')79 _entry(f, 'centerhost')80 elif opt in CENTER_CONFIG:81 f = _create_line(left, 'Ö÷¿Ø±êʶ')82 _combo(f, 'proxyserver')83 f = _create_line(left, '¾º¼¼³¡Ö÷¿Ø±êʶ')84 _combo(f, 'centersrv')85 f = _create_line(left, '¾º¼¼³¡Ö÷¿Ø¶Ë¿Ú')86 _entry(f, 'groupport')87 88 f = _create_line(right, '·þÎñÆ÷Ãû³Æ')89 _entry(f, 'srvname')90 f = _create_line(right, 'debug¶Ë¿Ú')91 _entry(f, 'debug')92 f = _create_line(right, '»úÆ÷ÈË')93 _combo(f, 'closerobot')94 if opt in GAME_CONFIG:95 f = _create_line(right, 'Ö÷¿Ø¶Ë¿Ú')96 _entry(f, 'proxyport')97 f = _create_line(right, '¾º¼¼³¡Ö÷¿Ø¶Ë¿Ú')98 _entry(f, 'groupport')99 elif opt in BATTLE_CONFIG:100 f = _create_line(right, 'Ö÷¿Ø¶Ë¿Ú')101 _entry(f, 'proxyport')102 f = _create_line(right, '¾º¼¼³¡Õ½¶··þ±êʶ')103 _combo(f, 'groupsrv')104 f = _create_line(right, '¾º¼¼³¡Ö÷¿Ø¶Ë¿Ú')105 _entry(f, 'centerport')106 elif opt in CENTER_CONFIG:107 f = _create_line(right, 'Ö÷¿Ø¶Ë¿Ú')108 _entry(f, 'proxyport')109 f = _create_line(right, '¾º¼¼³¡Ö÷¿Ø±êʶ2')110 _combo(f, 'groupsrv')111 112 # ×Ô¶¨ÒåÅäÖÃÇø113 f1 = Frame(self)114 f1.pack(fill='x')115 Label(f1, text='×Ô¶¨Òå').pack(side='left')116 sections = self.cfgdata.GetSections()117 _combo(f1, 'selfdefine_section', sections, width=10)118 _entry(f1, 'selfdefine_key', width=12)119 _entry(f1, 'selfdefine_value', width=18)120 self.SetData()121 122 def EditEnable(self):123 for name, control in self.controls.items(): ...

Full Screen

Full Screen

test_package_preparation_line.py

Source:test_package_preparation_line.py Github

copy

Full Screen

...24 'location_id': self.src_location.id,25 'location_dest_id': self.dest_location.id,26 'partner_id': self.partner.id,27 })28 def _create_line(self, preparation, product=None, quantity=0.0,29 lot_id=None):30 self.env['stock.quant']._update_available_quantity(31 self.product1, self.src_location, quantity, lot_id=lot_id)32 return self.env['stock.picking.package.preparation.line'].create({33 'name': 'test',34 'product_id': product and product.id or False,35 'product_uom_qty': quantity,36 'product_uom_id': product and product.uom_id.id or False,37 'package_preparation_id': preparation.id,38 'note': 'note',39 'lot_id': lot_id.id if lot_id else False40 })41 def _create_preparation(self, pickings=None):42 values = {'partner_id': self.partner.id, }43 if pickings:44 values.update({'picking_ids': [(6, 0, pickings.ids)], })45 return self.env['stock.picking.package.preparation'].create(values)46 def setUp(self):47 super(TestPackagePreparationLine, self).setUp()48 self.src_location = self.env.ref('stock.stock_location_stock')49 self.dest_location = self.env.ref('stock.stock_location_customers')50 self.partner = self.env.ref('base.res_partner_2')51 self.product1 = self.env.ref('product.product_product_16')52 self.product2 = self.env.ref('product.product_product_13')53 self.product3_not_available = self.env.ref('product.product_product_3')54 self.picking_type_out = self.env.ref('stock.picking_type_out')55 self.picking_type_out.default_location_dest_id = self.dest_location.id56 self.picking = self._create_picking()57 self.move = self._create_move(self.picking, self.product1)58 self.preparation = self._create_preparation()59 def test_preparation_line_empty(self):60 # Preparation is created without lines.61 # Test if line_ids is empty62 self.assertEqual(len(self.preparation.line_ids), 0)63 def test_auto_line_creation(self):64 # Add a picking in preparation65 # Test if a preparation line is created for the stock move66 self.preparation.picking_ids = [(6, 0, [self.picking.id, ])]67 self.assertEqual(len(self.preparation.line_ids), 1)68 def test_line_product_onchange(self):69 line = self._create_line(self.preparation, self.product2, 2.0)70 # Test onchange71 line._onchange_product_id()72 self.assertEqual(self.product2.display_name, line.name)73 self.assertEqual(self.product2.uom_id, line.product_uom_id)74 def test_not_available_product(self):75 self._create_line(self.preparation, self.product3_not_available, 1.0)76 with self.assertRaises(UserError):77 # picking not confirmed nor assigned78 self.preparation.action_put_in_pack()79 def test_move_and_picking_create_from_line(self):80 # Add a line in preparation81 # Test if a stock move and picking are created when "Put in Pack"82 # is used83 self._create_line(self.preparation, self.product2, 2.0)84 self.preparation.action_put_in_pack()85 self.assertEqual(len(self.preparation.picking_ids), 1)86 # Check if stock move and package preparation line have the some87 # name88 self.assertEqual(89 self.preparation.picking_ids[0].move_lines[0].name,90 self.preparation.line_ids[0].name91 )92 # Check if stock move and package preparation line have the some93 # quantity94 self.assertEqual(95 self.preparation.picking_ids[0].move_lines[0].product_uom_qty,96 self.preparation.line_ids[0].product_uom_qty97 )98 def test_change_qty_on_preparation_line(self):99 # Create a Preparation Line, then change qty on line100 # Test if qty on stock move are equals to qty on Preparation Line101 self._create_line(self.preparation, self.product2, 3.0)102 self.preparation.action_put_in_pack()103 # Modify qty on line104 test_line = self.preparation.line_ids[0]105 test_line.product_uom_qty = 4.0106 self.assertEqual(test_line.product_uom_qty,107 test_line.move_id.product_qty)108 def test_change_on_stock_move(self):109 # Change information on a stock move related with package110 # preparation line and check if this line has new information111 self._create_line(self.preparation, self.product2, 2.0)112 self.preparation.action_put_in_pack()113 # Change stock move name114 self.preparation.line_ids[0].move_id.name = 'Changed for test'115 self.assertEqual(self.preparation.line_ids[0].name,116 self.preparation.line_ids[0].move_id.name)117 def test_change_stock_move_quantity(self):118 # Create a package preparation line with relative stock move119 # to test a change on stock move quantity120 self._create_line(self.preparation, self.product2, 2.0)121 self.preparation.action_put_in_pack()122 self.preparation.line_ids[0].move_id.product_uom_qty = 3.0123 self.assertEqual(self.preparation.line_ids[0].product_uom_qty, 3.0)124 def test_package_with_description_line_and_product_line(self):125 # Create a package preparation with 2 line one of them is a126 # description line only to test picking have only one move127 self._create_line(self.preparation, self.product2, 1.0)128 self._create_line(self.preparation, quantity=0)129 self.preparation.action_put_in_pack()130 # Check have only one move line131 self.assertEqual(len(self.preparation.picking_ids[0].move_lines), 1)132 # Check product on move line is the same133 self.assertEqual(134 self.preparation.picking_ids[0].move_lines[0].product_id,135 self.product2)136 for line in self.preparation.line_ids:137 self.assertEqual(line.note, 'note')138 def test_remove_picking_from_package_preparation(self):139 # Remove picking from package preparation to test what happens140 # to package preparation line141 self.picking2 = self._create_picking()142 self._create_move(self.picking2, self.product2)143 self.preparation.picking_ids = [144 (6, 0, [self.picking.id, self.picking2.id])]145 self.preparation.picking_ids = [(3, self.picking.id)]146 self.assertEqual(len(self.preparation.line_ids), 1)147 def test_edit_picking_from_package_preparation(self):148 # Edit picking in package preparation to test what happens149 # to package preparation line150 self.picking2 = self._create_picking()151 self._create_move(self.picking2, self.product2)152 self.preparation.write({153 'picking_ids': [154 (6, 0, [self.picking.id, self.picking2.id])]})155 self.preparation.write({156 'picking_ids': [157 (1, self.picking.id, {'name': 'Test change name'})]})158 self.assertEquals(len(self.preparation.line_ids), 1)159 def test_standard_flow_with_detail_with_lot(self):160 # Test a standard flow of a package preparation but add a lot161 # on detail162 # Create a lot163 lot = self.env['stock.production.lot'].create({164 'name': self.product1.name,165 'product_id': self.product1.id,166 })167 self.product1.tracking = 'lot'168 # Add a line in preparation with lot169 quantity = 2.0170 self._create_line(self.preparation, self.product1, quantity,171 lot_id=lot)172 # Put In Pack173 self.preparation.action_put_in_pack()174 # Check operations175 self.assertEqual(len(self.preparation.move_line_ids), 1)176 # Check Lot on Operation177 self.assertEqual(178 self.preparation.move_line_ids[0].lot_id.id,179 lot.id)180 # Package Done181 src_quant = self.env['stock.quant']._gather(182 product_id=self.product1,183 location_id=self.src_location,184 lot_id=lot)...

Full Screen

Full Screen

test_product.py

Source:test_product.py Github

copy

Full Screen

...21 stock_quant._update_available_quantity(self.product_02, stock_location, 100.0)22 self.partner = self.env["res.partner"].create({"name": "Test Partner"})23 def test_01_compute_website_sale_available_qty(self):24 sale_order = self.env["sale.order"]25 def _create_line(product, qty, order):26 return self.env["sale.order.line"].create(27 {28 "product_id": product.id,29 "price_unit": 10.00,30 "product_uom": product.uom_id.id,31 "product_uom_qty": qty,32 "order_id": order.id,33 }34 )35 # Create an order with 'draft' state36 sale_order_01 = sale_order.create({"partner_id": self.partner.id})37 _create_line(self.product_01, 20.0, sale_order_01)38 _create_line(self.product_02, 30.0, sale_order_01)39 # Create an order with 'draft' state40 sale_order_02 = sale_order.create({"partner_id": self.partner.id})41 _create_line(self.product_01, 15.0, sale_order_02)42 # Create an order with 'sent' state43 sale_order_03 = sale_order.create({"partner_id": self.partner.id})44 _create_line(self.product_02, 10.0, sale_order_03)45 sale_order_03.print_quotation()46 self.assertEqual(self.product_01.draft_sale_qty, 35.0)47 self.assertEqual(self.product_01.sent_sale_qty, 0.0)48 self.assertEqual(self.product_02.draft_sale_qty, 30.0)49 self.assertEqual(self.product_02.sent_sale_qty, 10.0)50 # Check the result at product variant level51 self.assertEqual(self.product_01.website_sale_available_qty, 65.0)52 self.assertEqual(self.product_02.website_sale_available_qty, 60.0)53 # Check the result at product template level54 self.assertEqual(55 self.product_01.product_tmpl_id.website_sale_available_qty, 65.0,56 )57 self.assertEqual(58 self.product_02.product_tmpl_id.website_sale_available_qty, 60.0,...

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