예제 #1
0
    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client.update(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.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], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

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

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)
예제 #2
0
    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client.update(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)
        step.quantity.update(1)
        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.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], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

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

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)
예제 #3
0
    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1, unit_cost=10)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client_gadget.set_value(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)

        # This is a workaround to be able to set a value bigger than MAX_INT,
        # so we can get its validation
        step.quantity.get_adjustment().set_upper(MAX_INT + 1)
        # Checking values bigger than MAX_INT for quantity
        step.quantity.update(MAX_INT + 1)
        self.assertInvalid(step, ['quantity'])
        # Checking values bigger than we have on stock
        step.quantity.update(2)
        self.assertInvalid(step, ['quantity'])
        # Checking negative value
        step.quantity.update(-1)
        self.assertInvalid(step, ['quantity'])
        # Checking valid values
        step.quantity.update(1)
        self.assertValid(step, ['quantity'])

        # Checking negative value
        step.cost.update(-1)
        self.assertInvalid(step, ['cost'])
        # This is a workaround to be able to set a value bigger than MAX_INT,
        # so we can get its validation
        step.cost.get_adjustment().set_upper(MAX_INT + 1)
        # Checking values bigger than MAX_INT for cost
        step.cost.update(MAX_INT + 1)
        self.assertInvalid(step, ['cost'])
        # Checking valid value
        step.cost.update(10)
        self.assertValid(step, ['cost'])

        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.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], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

        yesno.assert_called_once_with(
            'Would you like to print the receipt now?', gtk.RESPONSE_YES,
            'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)
예제 #4
0
    def test_confirm(self, yesno, print_report):
        client = self.create_client()
        branch = api.get_current_branch(self.store)
        storable = self.create_storable(branch=branch, stock=1, unit_cost=10)
        sellable = storable.product.sellable
        wizard = NewLoanWizard(self.store)

        step = wizard.get_current_step()
        step.client_gadget.set_value(client)
        step.expire_date.update(localtoday().date())
        self.check_wizard(wizard, 'new-loan-wizard-start-step')
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.barcode.set_text(sellable.barcode)
        step.sellable_selected(sellable)

        # This is a workaround to be able to set a value bigger than MAX_INT,
        # so we can get its validation
        step.quantity.get_adjustment().set_upper(MAX_INT + 1)
        # Checking values bigger than MAX_INT for quantity
        step.quantity.update(MAX_INT + 1)
        self.assertInvalid(step, ['quantity'])
        # Checking values bigger than we have on stock
        step.quantity.update(2)
        self.assertInvalid(step, ['quantity'])
        # Checking negative value
        step.quantity.update(-1)
        self.assertInvalid(step, ['quantity'])
        # Checking valid values
        step.quantity.update(1)
        self.assertValid(step, ['quantity'])

        # Checking negative value
        step.cost.update(-1)
        self.assertInvalid(step, ['cost'])
        # This is a workaround to be able to set a value bigger than MAX_INT,
        # so we can get its validation
        step.cost.get_adjustment().set_upper(MAX_INT + 1)
        # Checking values bigger than MAX_INT for cost
        step.cost.update(MAX_INT + 1)
        self.assertInvalid(step, ['cost'])
        # Checking valid value
        step.cost.update(10)
        self.assertValid(step, ['cost'])

        self.click(step.add_sellable_button)
        loan_item = self.store.find(LoanItem, sellable=sellable).one()
        module = 'stoqlib.gui.events.NewLoanWizardFinishEvent.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], Loan))
        self.check_wizard(wizard, 'new-loan-wizard-item-step',
                          [wizard.retval, loan_item])

        yesno.assert_called_once_with('Would you like to print the receipt now?',
                                      gtk.RESPONSE_YES, 'Print receipt', "Don't print")
        self.assertEquals(print_report.call_count, 1)

        # verifies if stock was decreased correctly
        self.assertEquals(storable.get_balance_for_branch(branch), 0)