예제 #1
0
    def test_create(self, yesno, print_report):
        sellable = self.create_sellable(description=u"Product to transfer")
        self.create_storable(sellable.product,
                             get_current_branch(self.store),
                             stock=10)

        wizard = StockTransferWizard(self.store)
        self.assertSensitive(wizard, ['next_button'])
        self.check_wizard(wizard, 'wizard-stock-transfer-create')

        self.click(wizard.next_button)
        step = wizard.get_current_step()

        # No source or destination responsible selected. Finish is disabled
        self.assertNotSensitive(wizard, ['next_button'])

        # adds sellable to step
        step.sellable_selected(sellable)
        step._add_sellable()

        self.check_wizard(wizard, 'wizard-stock-transfer-products')

        module = 'stoqlib.gui.events.StockTransferWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            self.click(wizard.next_button)
            self.assertEquals(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], TransferOrder))

        yesno.assert_called_once_with(
            _('Would you like to print a receipt for this transfer?'),
            gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)
예제 #2
0
    def test_create(self, yesno, print_report):
        sellable = self.create_sellable(description=u"Product to transfer")
        self.create_storable(sellable.product, get_current_branch(self.store),
                             stock=10)

        wizard = StockTransferWizard(self.store)
        self.assertNotSensitive(wizard, ['next_button'])
        self.check_wizard(wizard, 'wizard-stock-transfer-create')

        step = wizard.get_current_step()
        step.destination_branch.set_active(0)
        self.assertSensitive(wizard, ['next_button'])

        self.click(wizard.next_button)
        step = wizard.get_current_step()

        # adds sellable to step
        step.sellable_selected(sellable)
        step._add_sellable()

        self.check_wizard(wizard, 'wizard-stock-transfer-products')

        module = 'stoqlib.gui.events.StockTransferWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            with mock.patch.object(self.store, 'commit'):
                self.click(wizard.next_button)
            self.assertEquals(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], TransferOrder))

        yesno.assert_called_once_with(
            _('Would you like to print a receipt for this transfer?'),
            gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)
    def test_create(self, yesno, print_report):
        sellable = self.create_sellable(description=u"Product to transfer")
        self.create_storable(sellable.product, get_current_branch(self.store),
                             stock=10)

        wizard = StockTransferWizard(self.store)
        self.assertNotSensitive(wizard, ['next_button'])
        self.check_wizard(wizard, 'wizard-stock-transfer-create')

        step = wizard.get_current_step()

        # adds sellable to step
        step.sellable_selected(sellable)
        step._add_sellable()

        self.check_wizard(wizard, 'wizard-stock-transfer-products')
        self.click(wizard.next_button)
        step = wizard.get_current_step()

        self.check_wizard(wizard, 'wizard-stock-transfer-finish-step')
        # No source or destination responsible selected. Finish is disabled
        self.assertNotSensitive(wizard, ['next_button'])

        employee = self.store.find(Employee)[0]

        # Select a source responsible
        step.source_responsible.select(employee)

        # Finish should still be disable until we select a destination
        # responsible
        self.assertNotSensitive(wizard, ['next_button'])
        step.destination_responsible.select(employee)

        module = 'stoqlib.gui.events.StockTransferWizardFinishEvent.emit'
        with mock.patch(module) as emit:
            self.click(wizard.next_button)
            self.assertEquals(emit.call_count, 1)
            args, kwargs = emit.call_args
            self.assertTrue(isinstance(args[0], TransferOrder))

        yesno.assert_called_once_with(
            _('Would you like to print a receipt for this transfer?'),
            gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)