当前位置: 首页>>代码示例>>Python>>正文


Python dateutils.localdate函数代码示例

本文整理汇总了Python中stoqlib.lib.dateutils.localdate函数的典型用法代码示例。如果您正苦于以下问题:Python localdate函数的具体用法?Python localdate怎么用?Python localdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了localdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_find_pending

    def test_find_pending(self):
        wo1 = self.create_workorder()
        wo1.status = WorkOrder.STATUS_OPENED
        wo2 = self.create_workorder()
        wo2.status = WorkOrder.STATUS_WORK_WAITING
        wo3 = self.create_workorder()
        wo3.status = WorkOrder.STATUS_WORK_IN_PROGRESS
        wo4 = self.create_workorder()
        wo4.status = WorkOrder.STATUS_WORK_FINISHED
        # Those 2 should not appear on the results
        wo5 = self.create_workorder()
        wo5.status = WorkOrder.STATUS_DELIVERED
        wo6 = self.create_workorder()
        wo6.status = WorkOrder.STATUS_CANCELLED

        work_orders = set(wov.work_order for wov in WorkOrderView.find_pending(self.store))
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))

        wo1.estimated_finish = localdate(2013, 1, 1)
        wo2.estimated_finish = localdate(2013, 2, 1)
        wo3.estimated_finish = localdate(2013, 3, 1)
        wo4.estimated_finish = localdate(2013, 4, 1)
        wo5.estimated_finish = localdate(2013, 1, 1)
        wo6.estimated_finish = localdate(2013, 2, 1)

        # Filtering by start date only
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, start_date=localdate(2013, 1, 1))
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, start_date=localdate(2013, 1, 2))
        )
        self.assertEqual(work_orders, set([wo2, wo3, wo4]))

        # Filtering by end date only
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, end_date=localdate(2013, 1, 2))
        )
        self.assertEqual(work_orders, set([wo1]))
        work_orders = set(
            wov.work_order for wov in WorkOrderView.find_pending(self.store, end_date=localdate(2013, 4, 2))
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))

        # Filtering by both start and end dates
        work_orders = set(
            wov.work_order
            for wov in WorkOrderView.find_pending(
                self.store, start_date=localdate(2013, 1, 1), end_date=localdate(2013, 4, 2)
            )
        )
        self.assertEqual(work_orders, set([wo1, wo2, wo3, wo4]))
        work_orders = set(
            wov.work_order
            for wov in WorkOrderView.find_pending(
                self.store, start_date=localdate(2013, 3, 1), end_date=localdate(2013, 4, 2)
            )
        )
        self.assertEqual(work_orders, set([wo3, wo4]))
开发者ID:amaurihamasu,项目名称:stoq,代码行数:60,代码来源:test_workorder.py

示例2: test_confirm

    def test_confirm(self):
        editor = OutPaymentEditor(self.store)
        self.assertFalse(editor.validate_confirm())
        editor.description.update('Payment name')
        self.assertFalse(editor.validate_confirm())

        editor.value.update(100)
        self.assertFalse(editor.validate_confirm())

        editor.due_date.update(localdate(2015, 1, 1).date())
        self.assertTrue(editor.validate_confirm())

        editor.repeat.update(INTERVALTYPE_WEEK)
        self.assertFalse(editor.validate_confirm())

        editor.end_date.update(localdate(2014, 1, 10).date())
        self.assertFalse(editor.validate_confirm())

        editor.end_date.update(localdate(2015, 1, 10).date())
        self.assertTrue(editor.validate_confirm())

        editor.main_dialog.confirm()

        model = editor.retval
        self.check_editor(editor, 'editor-payment-confirm',
                          [model.group] + list(model.group.payments))
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:26,代码来源:test_payment_editor.py

示例3: _create_domain

    def _create_domain(self):
        branch = get_current_branch(self.store)
        sale = self.create_sale(branch=branch)
        sale_item = self.create_sale_item(sale=sale)
        sale_item.quantity = 66
        sale_item.quantity_decreased = 23
        sale_item.sellable.description = u'Schrubbery'
        sale_item.sale.identifier = 42
        sale.status = sale.STATUS_ORDERED
        sale.open_date = localdate(2013, 12, 11)

        sale2 = self.create_sale(branch=branch)
        sale_item2 = self.create_sale_item(sale=sale2)
        sale_item2.quantity = 29
        sale_item2.quantity_decreased = 29
        sale_item2.sellable.description = u'Holy Grail'
        sale_item2.sale.identifier = 73
        sale2.open_date = localdate(2013, 12, 11)
        sale2.status = sale2.STATUS_QUOTE

        self.branch2 = self.create_branch(u'The Meaning of Life')
        sale3 = self.create_sale(branch=self.branch2)
        sale_item3 = self.create_sale_item(sale=sale3)
        sale_item3.quantity = 41
        sale_item3.quantity_decreased = 1
        sale_item3.sellable.description = u'The Funniest Joke in this Code'
        sale_item3.sale.identifier = 99
        sale3.open_date = localdate(2013, 12, 11)
        sale3.status = sale3.STATUS_QUOTE
开发者ID:pkaislan,项目名称:stoq,代码行数:29,代码来源:test_salessearch.py

示例4: test_estimated_finish

 def test_estimated_finish(self, localtoday_):
     workorder = self.create_workorder()
     slave = WorkOrderOpticalSlave(self.store, workorder)
     localtoday_.return_value = localdate(2014, 1, 1)
     res = slave.estimated_finish.emit("validate", localdate(2013, 1, 1))
     self.assertEquals(unicode(res),
                       u'Estimated finish date cannot be in the past.')
开发者ID:Joaldino,项目名称:stoq,代码行数:7,代码来源:test_optical_slave.py

示例5: test_get_birthday_date_query

    def test_get_birthday_date_query(self):
        start = localdate(2000, 3, 4)

        query = Individual.get_birthday_query(start)

        start_year = DateTrunc(u'year', Date(start))
        age_in_year = Age(Individual.birth_date,
                          DateTrunc(u'year', Individual.birth_date))
        test_query = (
            start_year + age_in_year +
            Case(condition=age_in_year < Age(Date(start), start_year),
                 result=Interval(u'1 year'),
                 else_=Interval(u'0 year'))
        )
        test_query = (test_query == Date(start))

        self.assertEquals(query, test_query)

        individuals = list(self.store.find(Individual, test_query))
        self.assertEquals(len(individuals), 0)

        client1 = self.create_client(u'Junio C. Hamano')
        client1.person.individual.birth_date = localdate(1972, 10, 15)
        client2 = self.create_client(u'Richard Stallman')
        client2.person.individual.birth_date = localdate(1989, 3, 4)
        client3 = self.create_client(u'Linus Torvalds')
        client3.person.individual.birth_date = localdate(2000, 3, 4)
        client4 = self.create_client(u'Guido van Rossum')
        client4.person.individual.birth_date = localdate(2005, 3, 4)

        individuals = list(self.store.find(Individual, test_query))
        self.assertEquals(len(individuals), 3)
        self.assertTrue(client2.person.individual in individuals)
        self.assertTrue(client3.person.individual in individuals)
        self.assertTrue(client4.person.individual in individuals)
开发者ID:rosalin,项目名称:stoq,代码行数:35,代码来源:test_person.py

示例6: _create_domain

    def _create_domain(self):
        address = self.create_address()
        service_item = self.create_sale_item()
        service_item.sale.identifier = 10
        service_item.sale.status = Sale.STATUS_CONFIRMED
        transporter = self.create_transporter(name=u'Hall')
        delivery = Delivery(transporter=transporter,
                            address=address,
                            invoice=service_item.sale.invoice,
                            open_date=localdate(2012, 1, 1).date(),
                            store=self.store)
        delivery.tracking_code = u'45'

        service_item = self.create_sale_item()
        service_item.sale.identifier = 20
        service_item.sale.status = Sale.STATUS_CONFIRMED
        transporter = self.create_transporter(name=u'Torvalds')
        delivery = Delivery(transporter=transporter,
                            address=address,
                            invoice=service_item.sale.invoice,
                            open_date=localdate(2012, 2, 2).date(),
                            send_date=localdate(2012, 3, 3).date(),
                            receive_date=localdate(2012, 4, 4).date(),
                            store=self.store)
        delivery.tracking_code = u'78'
        delivery.status = Delivery.STATUS_RECEIVED
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:test_deliverysearch.py

示例7: test_send

    def test_send(self, localnow):
        localnow.return_value = localdate(2013, 1, 1)

        package = self.create_workorder_package()
        package.destination_branch = self.create_branch()
        workorder1 = self.create_workorder()
        workorder2 = self.create_workorder()

        with mock.patch('stoqlib.domain.workorder.get_current_branch') as gcb:
            gcb.return_value = self.create_branch()
            with self.assertRaisesRegexp(
                    ValueError,
                    ("This package's source branch is <Branch u'[0-9a-f-]+'> "
                     "and you are in <Branch u'[0-9a-f-]+'>. It's not possible "
                     "to send a package outside the source branch")):
                package.send()

        with self.assertRaisesRegexp(
                ValueError, "There're no orders to send"):
            package.send()

        for order in [workorder1, workorder2]:
            self.assertNotEqual(order.branch, None)
            self.assertEqual(order.branch, order.current_branch)
            package.add_order(order)

        self.assertEqual(package.status, WorkOrderPackage.STATUS_OPENED)
        self.assertEqual(package.send_date, None)
        package.send()
        self.assertEqual(package.status, WorkOrderPackage.STATUS_SENT)
        self.assertEqual(package.send_date, localdate(2013, 1, 1))

        for order in [workorder1, workorder2]:
            self.assertEqual(order.current_branch, None)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:34,代码来源:test_workorder.py

示例8: _create_domain

    def _create_domain(self):
        self.clean_domain([Commission, SaleItem, Sale])

        branches = self.store.find(Branch)

        sale = self.create_sale(branch=branches[0])
        sale_item = self.create_sale_item(sale=sale)
        self.create_storable(sale_item.sellable.product, branches[0], 10)
        self.create_payment(payment_type=Payment.TYPE_IN, group=sale.group)
        sale.order()
        sale.confirm()
        sale_item.sellable.code = u'1'
        sale_item.sellable.description = u'Luvas'
        sale.open_date = localdate(2012, 1, 1).date()
        sale.confirm_date = localdate(2012, 1, 1).date()

        sale = self.create_sale(branch=branches[1])
        sale_item = self.create_sale_item(sale=sale)
        self.create_storable(sale_item.sellable.product, branches[0], 10)
        self.create_payment(payment_type=Payment.TYPE_IN, group=sale.group)
        sale.order()
        sale.confirm()
        sale_item.sellable.code = u'2'
        sale_item.sellable.description = u'Botas'
        sale.open_date = localdate(2012, 2, 2).date()
        sale.confirm_date = localdate(2012, 2, 2).date()
开发者ID:leandrorchaves,项目名称:stoq,代码行数:26,代码来源:test_salessearch.py

示例9: test_receive

    def test_receive(self, localnow):
        localnow.return_value = localdate(2013, 1, 1)

        package = self.create_workorder_package(
            source_branch=self.create_branch())
        package.destination_branch = get_current_branch(self.store)
        workorder1 = self.create_workorder(current_branch=package.source_branch)
        workorder2 = self.create_workorder(current_branch=package.source_branch)

        # Mimic WorkOrderPackage.send
        for order in [workorder1, workorder2]:
            package.add_order(order)
            order.current_branch = None
        package.status = WorkOrderPackage.STATUS_SENT

        with mock.patch('stoqlib.domain.workorder.get_current_branch') as gcb:
            gcb.return_value = self.create_branch()
            with self.assertRaisesRegexp(
                    ValueError,
                    ("This package's destination branch is <Branch u'[0-9a-f-]+'> "
                     "and you are in <Branch u'[0-9a-f-]+'>. It's not possible "
                     "to receive a package outside the destination branch")):
                package.receive()

        self.assertEqual(package.receive_date, None)
        package.receive()
        self.assertEqual(package.status, WorkOrderPackage.STATUS_RECEIVED)
        self.assertEqual(package.receive_date, localdate(2013, 1, 1))

        for order in [workorder1, workorder2]:
            self.assertEqual(order.current_branch, package.destination_branch)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:31,代码来源:test_workorder.py

示例10: test_create_repeated_with_temporary_identifier

 def test_create_repeated_with_temporary_identifier(self):
     payment = self.create_payment()
     payment.description = u'temporary'
     payments = Payment.create_repeated(self.store, payment,
                                        INTERVALTYPE_MONTH,
                                        localdate(2012, 1, 1).date(),
                                        localdate(2012, 3, 1).date(),
                                        temporary_identifiers=True)
     (self.assertTrue(p.identifier < 0) for p in payments)
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:test_payment.py

示例11: test_optical_sales

    def test_optical_sales(self):
        app = self.create_app(SalesApp, u'sales')
        for sales in app.results:
            sales.open_date = localdate(2012, 1, 1)
            sales.confirm_date = localdate(2012, 2, 3)
            sales.close_date = localdate(2012, 4, 5)
        self.check_app(app, u'sales-optical-plugin')

        self.window.hide_app(empty=True)
开发者ID:Joaldino,项目名称:stoq,代码行数:9,代码来源:test_optical_ui.py

示例12: test_prescription_date

 def test_prescription_date(self, localtoday_):
     localtoday_.return_value = localdate(2014, 1, 1)
     not_late_date = localdate(2013, 6, 1).date()
     late_date = localdate(2012, 1, 1).date()
     workorder = self.create_workorder()
     slave = WorkOrderOpticalSlave(self.store, workorder)
     slave.prescription_date.set_date(localdate(2014, 1, 1))
     slave.prescription_date.set_date(not_late_date)
     slave.prescription_date.set_date(late_date)
     slave.prescription_date.set_date(None)
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:test_optical_slave.py

示例13: test_expire_date_validate

    def test_expire_date_validate(self, localtoday_):
        localtoday_.return_value = localdate(2020, 1, 5)

        wizard = OpticalSaleQuoteWizard(self.store)
        step = wizard.get_current_step()

        res = step.expire_date.emit('validate', localdate(2013, 1, 1).date())
        self.assertEquals(
            unicode(res),
            u"The expire date must be set to today or a future date.")
开发者ID:reashninja,项目名称:stoq,代码行数:10,代码来源:test_optical_wizard.py

示例14: _create_domain

 def _create_domain(self, localnow):
     self.clean_domain([WorkOrder])
     localnow.return_value = localdate(2014, 1, 1)
     work_order = self.create_workorder()
     work_order.open_date = localdate(2014, 1, 1)
     work_order.identifier = 123
     work_order.approve()
     work_order.work()
     work_order.add_sellable(self.create_sellable(), quantity=1)
     work_order.finish()
开发者ID:amaurihamasu,项目名称:stoq,代码行数:10,代码来源:test_workordersearch.py

示例15: test_estimated_finish

 def test_estimated_finish(self, localtoday_):
     workorder = self.create_workorder()
     workorder.open_date = localdate(2015, 4, 2)
     slave = WorkOrderOpticalSlave(self.store, workorder)
     #localtoday_.return_value = localdate(2014, 1, 1)
     res = slave.estimated_finish.emit("validate", localdate(2015, 4, 1))
     self.assertEqual(str(res),
                      u'Estimated finish date cannot be in the past.')
     # Can be edited without changing the estimated_finish
     res2 = slave.estimated_finish.emit("validate", localdate(2015, 4, 2))
     self.assertEqual(res2, None)
开发者ID:hackedbellini,项目名称:stoq,代码行数:11,代码来源:test_optical_slave.py


注:本文中的stoqlib.lib.dateutils.localdate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。