def test_unknown_sale_item_step(self): with self.sysparam(ALLOW_TRADE_NOT_REGISTERED_SALES=True): package = self.create_product(description=u'Package', is_package=True) package.sellable.barcode = u'666' component = self.create_product(description=u'Component', stock=2) self.create_product_component(product=package, component=component) production = self.create_production_item() production.product.sellable.barcode = u'333' wizard = SaleTradeWizard(self.store) step = wizard.get_current_step() self.click(step.unknown_sale_check) self.click(wizard.next_button) item_step = wizard.get_current_step() # Testing add package_item item_step.barcode.set_text(u'666') self.activate(item_step.barcode) self.click(item_step.add_sellable_button) # Children must be added to the list self.assertEqual(len(list(item_step.slave.klist)), 2) # Testing add production item item_step.barcode.set_text(u'333') self.activate(item_step.barcode) self.click(item_step.add_sellable_button) # For production item, we should not add its components to the list self.assertEqual(len(list(item_step.slave.klist)), 3)
def test_sale_selection_step_known_sale(self): wizard = SaleTradeWizard(self.store) step = wizard.get_current_step() results = step.slave.results # Since ALLOW_TRADE_NOT_REGISTERED_SALES is False (default), # the user should not be able to check this self.assertNotVisible(step, ['unknown_sale_check']) # next_button should only be sensitive if a sale is selected self.assertNotSensitive(wizard, ['next_button']) results.select(results[0]) self.assertSensitive(wizard, ['next_button']) results.unselect_all() self.assertNotSensitive(wizard, ['next_button']) self.check_wizard(wizard, 'wizard-trade-sale-selection-step-known-sale') # Go to items step results.select(results[0]) self.click(wizard.next_button) # Go to details step self.click(wizard.next_button) step = wizard.get_current_step() self.assertNotSensitive(wizard, ['next_button']) step.reason.update('Just because') self.assertSensitive(wizard, ['next_button']) module = 'stoqlib.gui.events.SaleTradeWizardFinishEvent.emit' with mock.patch(module) as emit: self.click(wizard.next_button) emit.assert_called_once_with(wizard.model)
def test_unknown_sale_item_step(self): with self.sysparam(ALLOW_TRADE_NOT_REGISTERED_SALES=True): package = self.create_product(description=u'Package', is_package=True) package.sellable.barcode = u'666' component = self.create_product(description=u'Component', stock=2) self.create_product_component(product=package, component=component) production = self.create_production_item() production.product.sellable.barcode = u'333' wizard = SaleTradeWizard(self.store) step = wizard.get_current_step() self.click(step.unknown_sale_check) self.click(wizard.next_button) item_step = wizard.get_current_step() # Testing add package_item item_step.barcode.set_text(u'666') self.activate(item_step.barcode) self.click(item_step.add_sellable_button) # Children must be added to the list self.assertEquals(len(list(item_step.slave.klist)), 2) # Testing add production item item_step.barcode.set_text(u'333') self.activate(item_step.barcode) self.click(item_step.add_sellable_button) # For production item, we should not add its components to the list self.assertEquals(len(list(item_step.slave.klist)), 3)
def test_sale_selection_step_known_sale(self): wizard = SaleTradeWizard(self.store) step = wizard.get_current_step() results = step.slave.results # Since ALLOW_TRADE_NOT_REGISTERED_SALES is False (default), # the user should not be able to check this self.assertNotVisible(step, ['unknown_sale_check']) # next_button should only be sensitive if a sale is selected self.assertNotSensitive(wizard, ['next_button']) results.select(results[0]) self.assertSensitive(wizard, ['next_button']) results.unselect_all() self.assertNotSensitive(wizard, ['next_button']) self.check_wizard(wizard, 'wizard-trade-sale-selection-step-known-sale') # Go to items step results.select(results[0]) self.click(wizard.next_button) # Go to details step self.click(wizard.next_button) step = wizard.get_current_step() self.assertNotSensitive(wizard, ['next_button']) step.invoice_number.update(41235) self.assertNotSensitive(wizard, ['next_button']) step.reason.update('Just because') self.assertSensitive(wizard, ['next_button']) module = 'stoqlib.gui.events.SaleTradeWizardFinishEvent.emit' with mock.patch(module) as emit: self.click(wizard.next_button) emit.assert_called_once_with(wizard.model)
def test_sale_selection_step_unknown_sale(self): sysparam.set_bool(self.store, 'ALLOW_TRADE_NOT_REGISTERED_SALES', True) wizard = SaleTradeWizard(self.store) step = wizard.get_current_step() results = step.slave.results # Since ALLOW_TRADE_NOT_REGISTERED_SALES is True, # the user should be able to check this self.assertVisible(step, ['unknown_sale_check']) # next_button should only be sensitive if a sale is selected self.assertNotSensitive(wizard, ['next_button']) results.select(results[0]) self.assertSensitive(wizard, ['next_button']) results.unselect_all() self.assertNotSensitive(wizard, ['next_button']) self.click(step.unknown_sale_check) self.assertSensitive(wizard, ['next_button']) self.check_wizard(wizard, 'wizard-trade-sale-selection-step-unknown-sale')