def test_attach_slave(self): sale = self.create_sale() sale.identifier = 1001 # SaleDetailsDialog needs a SaleView model model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) dialog.attach_slave("coupon_number_holder", CouponNumberSlave(self.store, model)) self.check_dialog(dialog, "dialog-saledetails-with-couponumberslave")
def test_attach_slave(self): sale = self.create_sale() sale.identifier = 1001 sale.open_date = localdate(2012, 12, 21) # SaleDetailsDialog needs a SaleView model model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) dialog.attach_slave('coupon_number_holder', CouponNumberSlave(self.store, model)) self.check_dialog(dialog, 'dialog-saledetails-with-couponumberslave')
def test_show(self): sale = self._create_sale() # SaleDetailsDialog needs a SaleView model model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.assertTrue(isinstance(dialog.items_list, ObjectTree)) self.check_editor(dialog, 'dialog-sale-details')
def test_show_with_returns_and_comments(self, print_report): date = localdate(2010, 12, 10).date() sale = self._create_sale() returned_sale = sale.create_sale_return_adapter( self.current_branch, self.current_user, self.current_station) returned_sale.return_(self.current_user) returned_sale.return_date = date # payments[0] is the sale's payment created on self._create_sale returned_payment = returned_sale.group.payments.find( Payment.identifier != 999).one() returned_payment.identifier = 666 returned_payment.due_date = date returned_payment.paid_date = date comment = self.create_sale_comment(sale) comment.date = date model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.click(dialog.print_return_report) self.check_editor(dialog, 'dialog-sale-details-with-returns')
def test_print_details(self, print_report): sale = self.create_sale() sale.client = self.create_client() self.create_sale_item(sale, product=True) model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.assertSensitive(dialog, ['print_button']) self.click(dialog.print_button) print_report.assert_called_once_with(SaleOrderReport, sale)
def test_print_booklet(self, print_report): sale = self.create_sale() sale.client = self.create_client() self.create_sale_item(sale, product=True) payment = self.add_payments(sale, u'store_credit')[0] model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.assertSensitive(dialog, ['print_booklets']) self.assertNotVisible(dialog, ['print_bills']) self.click(dialog.print_booklets) print_report.assert_called_once_with(BookletReport, [payment])
def test_client_details(self, run_dialog): sale = self.create_sale() sale.client = self.create_client() self.create_sale_item(sale, product=True) model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.click(dialog.details_button) args, kwargs = run_dialog.call_args editor, parent, store, model = args self.assertEquals(editor, ClientDetailsDialog) self.assertEquals(parent, dialog) self.assertEquals(model, sale.client) self.assertTrue(isinstance(store, StoqlibStore))
def test_print_bill(self, print_report, check_printable): sale = self.create_sale() sale.client = self.create_client() self.create_sale_item(sale, product=True) payment = self.add_payments(sale, u'bill')[0] model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.assertSensitive(dialog, ['print_bills']) self.assertNotVisible(dialog, ['print_booklets']) # Just make sure we can print the bill check_printable.return_value = True self.click(dialog.print_bills) print_report.assert_called_once_with(BillReport, [payment])
def test_show_package_product(self): sale = self.create_sale() package = self.create_product(description=u'Package', is_package=True) component1 = self.create_product(description=u'Component 1', stock=3) component2 = self.create_product(description=u'Component 2', stock=2) self.create_product_component(product=package, component=component1) self.create_product_component(product=package, component=component2) parent = sale.add_sellable(package.sellable, quantity=1) sale.add_sellable(component1.sellable, quantity=1, parent=parent) sale.add_sellable(component2.sellable, quantity=1, parent=parent) sale.create_sale_return_adapter() model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.assertEqual(len(list(dialog.items_list)), 3)
def testShowWithReturns(self): date = localdate(2010, 12, 10).date() sale = self._create_sale() returned_sale = sale.create_sale_return_adapter() returned_sale.return_() returned_sale.return_date = date # payments[0] is the sale's payment created on self._create_sale returned_payment = returned_sale.group.payments[1] returned_payment.identifier = 666 returned_payment.due_date = date returned_payment.paid_date = date model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.check_editor(dialog, 'dialog-sale-details-with-returns')
def test_add_note(self, run_dialog, new_store): new_store.return_value = self.store run_dialog.return_value = False sale = self.create_sale() sale.client = self.create_client() self.create_sale_item(sale, product=True) model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) with mock.patch.object(self.store, 'commit'): with mock.patch.object(self.store, 'close'): self.click(dialog.comment_add) args, kwargs = run_dialog.call_args editor, parent, store, model, prop_name = args self.assertEqual(editor, NoteEditor) self.assertEqual(parent, dialog) self.assertTrue(isinstance(model, SaleComment)) self.assertTrue(isinstance(store, StoqlibStore)) self.assertEqual(prop_name, 'comment') self.assertEqual(kwargs['title'], 'New Sale Comment')
def test_show(self): sale = self._create_sale() # SaleDetailsDialog needs a SaleView model model = self.store.find(SaleView, id=sale.id).one() dialog = SaleDetailsDialog(self.store, model) self.check_editor(dialog, 'dialog-sale-details')