예제 #1
0
    def test_remove(self):
        workorder = self.create_workorder(description=u'Test equipment')
        workorder.client = self.create_client()
        editor = _WorkOrderItemSlave(store=self.store, parent=None,
                                     model=workorder)
        self.assertEqual(len(editor.slave.klist), 0)

        product = self.create_product(branch=workorder.branch, stock=10)
        sellable = product.sellable
        sellable.barcode = u'666333999'
        storable = product.storable

        editor.barcode.set_text(u'666333999')
        self.activate(editor.barcode)
        editor.quantity.update(6)
        self.click(editor.add_sellable_button)

        # Make sure that the sellable (and only it) was added to the list
        self.assertEqual(len(editor.slave.klist), 1)
        self.assertEqual(sellable, editor.slave.klist[0].sellable)

        editor.slave.klist.select(editor.slave.klist[0])
        with mock.patch('stoqlib.gui.base.lists.yesno') as yesno:
            yesno.return_value = True
            self.click(editor.slave.delete_button)
            yesno.assert_called_once_with(
                'Delete this item?', gtk.RESPONSE_NO, 'Delete item', 'Keep it')

        self.assertEqual(len(editor.slave.klist), 0)
        self.assertEqual(
            storable.get_balance_for_branch(workorder.branch), 10)
예제 #2
0
 def test_show_with_sale(self):
     workorder = self.create_workorder(description=u'Test equipment')
     workorder.sale = self.create_sale()
     workorder.client = self.create_client()
     editor = _WorkOrderItemSlave(store=self.store, parent=None,
                                  model=workorder)
     self.check_slave(editor, 'slave-workorderitem-with-sale-show')
예제 #3
0
    def test_remove(self):
        workorder = self.create_workorder(description=u'Test equipment')
        workorder.client = self.create_client()
        editor = _WorkOrderItemSlave(store=self.store, parent=None,
                                     model=workorder)
        self.assertEqual(len(editor.slave.klist), 0)

        product = self.create_product(branch=workorder.branch, stock=10)
        sellable = product.sellable
        sellable.barcode = u'666333999'
        storable = product.storable

        editor.barcode.set_text(u'666333999')
        self.activate(editor.barcode)
        editor.quantity.update(6)
        self.click(editor.add_sellable_button)

        # Make sure that the sellable (and only it) was added to the list
        self.assertEqual(len(editor.slave.klist), 1)
        self.assertEqual(sellable, editor.slave.klist[0].sellable)

        editor.slave.klist.select(editor.slave.klist[0])
        with mock.patch('stoqlib.gui.base.lists.yesno') as yesno:
            yesno.return_value = True
            self.click(editor.slave.delete_button)
            yesno.assert_called_once_with(
                'Delete this item?', Gtk.ResponseType.NO, 'Delete item', 'Keep it')

        self.assertEqual(len(editor.slave.klist), 0)
        self.assertEqual(
            storable.get_balance_for_branch(workorder.branch), 10)
예제 #4
0
 def test_show_with_sale(self):
     workorder = self.create_workorder(description=u'Test equipment')
     workorder.sale = self.create_sale()
     workorder.client = self.create_client()
     editor = _WorkOrderItemSlave(store=self.store, parent=None,
                                  model=workorder)
     self.check_slave(editor, 'slave-workorderitem-with-sale-show')
예제 #5
0
    def test_remove(self):
        workorder = self.create_workorder(equipment=u'Test equipment')
        workorder.client = self.create_client()
        editor = _WorkOrderItemSlave(store=self.store,
                                     parent=None,
                                     model=workorder)
        self.assertEqual(len(editor.slave.klist), 0)

        product = self.create_product(branch=workorder.branch, stock=10)
        sellable = product.sellable
        sellable.barcode = u'666333999'
        storable = product.storable

        # Test synchronizing stoq (like if the user confirmed the wizard, came
        # back and removed the item) and not synchronizing (like if he added
        # and removed the item).
        # sync_stock is called on WorkOrderEditor at on_confirm
        for sync_stock in [True, False]:
            editor.barcode.set_text(u'666333999')
            self.activate(editor.barcode)
            editor.quantity.update(6)
            self.click(editor.add_sellable_button)

            # Make sure that the sellable (and only it) was added to the list
            self.assertEqual(len(editor.slave.klist), 1)
            self.assertEqual(sellable, editor.slave.klist[0].sellable)

            if sync_stock:
                # This is done on the WorkOrderEditor when closing it
                # Mimicing the behaviour
                workorder.sync_stock()
                self.assertEqual(
                    storable.get_balance_for_branch(workorder.branch), 4)

            editor.slave.klist.select(editor.slave.klist[0])
            with mock.patch('stoqlib.gui.base.lists.yesno') as yesno:
                yesno.return_value = True
                self.click(editor.slave.delete_button)
                yesno.assert_called_once_with('Delete this item?',
                                              gtk.RESPONSE_NO, 'Delete item',
                                              'Keep it')

            self.assertEqual(len(editor.slave.klist), 0)
            self.assertEqual(storable.get_balance_for_branch(workorder.branch),
                             10)
예제 #6
0
    def test_remove(self):
        workorder = self.create_workorder(equipment=u'Test equipment')
        workorder.client = self.create_client()
        editor = _WorkOrderItemSlave(store=self.store, parent=None,
                                     model=workorder)
        self.assertEqual(len(editor.slave.klist), 0)

        product = self.create_product(branch=workorder.branch, stock=10)
        sellable = product.sellable
        sellable.barcode = u'666333999'
        storable = product.storable

        # Test synchronizing stoq (like if the user confirmed the wizard, came
        # back and removed the item) and not synchronizing (like if he added
        # and removed the item).
        # sync_stock is called on WorkOrderEditor at on_confirm
        for sync_stock in [True, False]:
            editor.barcode.set_text(u'666333999')
            self.activate(editor.barcode)
            editor.quantity.update(6)
            self.click(editor.add_sellable_button)

            # Make sure that the sellable (and only it) was added to the list
            self.assertEqual(len(editor.slave.klist), 1)
            self.assertEqual(sellable, editor.slave.klist[0].sellable)

            if sync_stock:
                # This is done on the WorkOrderEditor when closing it
                # Mimicing the behaviour
                workorder.sync_stock()
                self.assertEqual(
                    storable.get_balance_for_branch(workorder.branch), 4)

            editor.slave.klist.select(editor.slave.klist[0])
            with mock.patch('stoqlib.gui.base.lists.yesno') as yesno:
                yesno.return_value = True
                self.click(editor.slave.delete_button)
                yesno.assert_called_once_with(
                    'Delete this item?', gtk.RESPONSE_NO, 'Delete item', 'Keep it')

            self.assertEqual(len(editor.slave.klist), 0)
            self.assertEqual(
                storable.get_balance_for_branch(workorder.branch), 10)