def test_show_item_editor(self): sellable = self.create_sellable() sellable.cost = 100 transfer_item = self.create_transfer_order_item(sellable=sellable, quantity=10, stock_cost=150) editor = TransferItemEditor(self.store, transfer_item) self.check_editor(editor, 'editor-transfer-item-edit') with mock.patch('stoqlib.lib.pluginmanager.PluginManager.is_active') as patch: patch.return_value = True editor = TransferItemEditor(self.store, transfer_item) self.check_editor(editor, 'editor-transfer-item-with-nfe')
def test_update_taxes(self): tax_template = ProductTaxTemplate( store=self.store, tax_type=ProductTaxTemplate.TYPE_ICMS) icms_template = ProductIcmsTemplate(store=self.store, product_tax_template=tax_template) icms_template.csosn = 201 tax_template = ProductTaxTemplate(store=self.store, tax_type=ProductTaxTemplate.TYPE_IPI) ipi_template = ProductIpiTemplate(store=self.store, product_tax_template=tax_template) ipi_template.cst = 00 product = self.create_product() product.icms_template = icms_template product.ipi_template = ipi_template transfer_item = self.create_transfer_order_item( sellable=product.sellable, stock_cost=100, quantity=1) with mock.patch( 'stoqlib.lib.pluginmanager.PluginManager.is_active') as patch: patch.return_value = True editor = TransferItemEditor(self.store, transfer_item) slave = editor.item_slave icms_slave = editor.icms_slave ipi_slave = editor.ipi_slave self.assertEquals(icms_slave.v_bc_st.read(), 100) self.assertEquals(ipi_slave.v_bc.read(), 100) slave.stock_cost.update(150) self.assertEquals(icms_slave.v_bc_st.read(), 150) self.assertEquals(ipi_slave.v_bc.read(), 150) slave.quantity.update(2) self.assertEquals(icms_slave.v_bc_st.read(), 300) self.assertEquals(ipi_slave.v_bc.read(), 300)
def test_on_stock_cost__validate(self): transfer_item = self.create_transfer_order_item(stock_cost=150) editor = TransferItemEditor(self.store, transfer_item) slave = editor.item_slave self.assertEqual(slave.stock_cost.get_value(), 150) slave.stock_cost.update(0) self.assertInvalid(slave, ['stock_cost']) slave.stock_cost.update(100) self.assertValid(slave, ['stock_cost'])
def test_on_quantity__validate(self): transfer_item = self.create_transfer_order_item(quantity=10) editor = TransferItemEditor(self.store, transfer_item) slave = editor.item_slave self.assertEqual(slave.quantity.get_value(), 10) slave.quantity.update(0) self.assertInvalid(slave, ['quantity']) slave.quantity.update(1) self.assertValid(slave, ['quantity'])
def test_show(self): sellable = self.create_sellable() sellable.cost = 100 transfer_item = self.create_transfer_order_item(sellable=sellable, quantity=10, stock_cost=150) editor = TransferItemEditor(self.store, transfer_item) slave = editor.item_slave self.assertEqual(slave.original_cost.read(), 100) self.assertEqual(slave.stock_cost.read(), 150) self.assertEqual(slave.quantity.get_value(), 10) self.check_slave(slave, 'slave-transfer-item-show')