本文整理汇总了Python中stoqlib.lib.dateutils.localdatetime函数的典型用法代码示例。如果您正苦于以下问题:Python localdatetime函数的具体用法?Python localdatetime怎么用?Python localdatetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了localdatetime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_return_from_execution
def test_create_return_from_execution(self, localnow):
current_branch = api.get_current_branch(self.store)
current_branch.can_execute_foreign_work_orders = True
localnow.return_value = localdatetime(2013, 1, 1)
destination_branch = self.create_branch()
workorders_ids = set()
for i in xrange(10):
wo = self.create_workorder(description=u"Equipment %d" % i)
wo.client = self.create_client()
wo.identifier = 666 + i
wo.open_date = localdatetime(2013, 1, 1)
# Only the 3 finished and with their original branches set to the
# destination_branch will appear on the list
if i < 3:
wo.approve()
elif 3 <= i < 6:
wo.approve()
wo.work()
wo.add_sellable(self.create_sellable())
wo.finish()
elif 6 <= i < 9:
wo.approve()
wo.work()
wo.add_sellable(self.create_sellable())
wo.finish()
wo.branch = destination_branch
workorders_ids.add(wo.id)
editor = WorkOrderPackageSendEditor(self.store)
self.assertInvalid(editor, ['destination_branch'])
self.assertEqual(len(editor.workorders), 0)
editor.destination_branch.update(destination_branch)
self.assertValid(editor, ['destination_branch'])
self.assertEqual(workorders_ids,
set([wo_.id for wo_ in editor.workorders]))
self.assertEqual(editor.model.package_items.count(), 0)
# Only these 2 will be sent
for wo in [editor.workorders[0], editor.workorders[1]]:
wo.will_send = True
# Mimic 'cell-edited' emission
editor.workorders.emit('cell_edited', wo, 'will_send')
self.assertNotSensitive(editor.main_dialog, ['ok_button'])
self.assertInvalid(editor, ['identifier'])
editor.identifier.update(u'123321')
self.assertValid(editor, ['identifier'])
self.assertSensitive(editor.main_dialog, ['ok_button'])
self.check_editor(
editor, 'editor-workorderpackagesend-return-from-execution-create')
with mock.patch.object(editor.model, 'send') as send:
self.click(editor.main_dialog.ok_button)
self.assertEqual(send.call_count, 1)
self.assertEqual(editor.model.package_items.count(), 2)
示例2: _create_domain
def _create_domain(self):
self.clean_domain([TransferOrderItem, TransferOrder])
source_branch = Branch.get_active_remote_branches(self.store)[0]
dest_branch = api.get_current_branch(self.store)
# Created order, did not send it yet.
order = self.create_transfer_order(source_branch=source_branch,
dest_branch=dest_branch)
self.create_transfer_order_item(order=order)
order.identifier = 75168
order.open_date = localdatetime(2012, 1, 1)
# Created and sent the order.
order = self.create_transfer_order(source_branch=source_branch,
dest_branch=dest_branch)
self.create_transfer_order_item(order=order)
order.identifier = 56832
order.open_date = localdatetime(2012, 2, 2)
order.send()
# Order arrived at the destination.
order = self.create_transfer_order(source_branch=source_branch,
dest_branch=dest_branch)
self.create_transfer_order_item(order=order)
order.identifier = 20486
order.open_date = localdatetime(2012, 3, 3)
order.send()
order.receive(self.create_employee())
order.receival_date = localdatetime(2012, 3, 4)
示例3: __init__
def __init__(self):
self.api = mock.Mock()
self.api.get_current_branch = get_current_branch
self.DatabaseSettings = FakeDatabaseSettings
self.StoqConfig = FakeStoqConfig
self.datetime = mock.MagicMock(datetime)
self.datetime.datetime.today.return_value = localdatetime(2012, 1, 1)
self.datetime.datetime.now.return_value = localdatetime(2012, 1, 1)
self.datetime.date.today.return_value = localdate(2012, 1, 1).date()
示例4: test_show
def test_show(self, localnow):
sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
localnow.return_value = localdatetime(2013, 2, 1)
sellable = self.create_sellable(code=u'Code')
workorder = self.create_workorder(description=u'Test equipment')
workorder.identifier = 666
workorder.supplier_order = u"A1234"
workorder.client = self.create_client()
workorder.sellable = sellable
workorder.category = WorkOrderCategory(store=self.store,
name=u'Categoty XXX')
workorder.defect_reported = u"Defect reported"
# Create the editor and check initial state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-initial')
self.assertEqual(editor.supplier_order.read(), u'A1234')
self.assertSensitive(editor, ['client'])
self.assertSensitive(editor, ['category', 'category_create'])
self.assertSensitive(editor, ['supplier_order'])
workorder.defect_detected = u"Defect detected"
workorder.estimated_hours = 10
workorder.estimated_hours = 100
workorder.estimated_start = localdatetime(2013, 1, 1)
workorder.estimated_finish = localdatetime(2013, 1, 2)
workorder.approve()
_adjust_history_date(workorder)
# Create another editor to check approved state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-approved')
workorder.add_sellable(self.create_sellable(description=u"Product A"),
price=99, quantity=2)
workorder.add_sellable(self.create_sellable(description=u"Product B"),
price=5, quantity=100)
workorder.work()
_adjust_history_date(workorder)
# Create another editor to check work in progress state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-in-progress')
workorder.finish()
_adjust_history_date(workorder)
# Create another editor to check finished state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-finished')
for item in workorder.order_items:
item.reserve(item.quantity)
workorder.close()
_adjust_history_date(workorder)
# Create another editor to check closed state
editor = WorkOrderEditor(self.store, model=workorder)
self.check_editor(editor, 'editor-workorder-show-closed')
示例5: test_close_returned_in_consignment_wizard
def test_close_returned_in_consignment_wizard(self, run_dialog, info):
purchase_item = self.create_purchase_order_item()
self.create_receiving_order_item(purchase_item=purchase_item)
# Create storable.
product = purchase_item.sellable.product
Storable(store=self.store, product=product)
storable = product.storable
branch = purchase_item.order.branch
storable.increase_stock(5, branch,
StockTransactionHistory.TYPE_INITIAL, None)
stock_quantity = storable.get_stock_item(branch, None).quantity
self.assertEqual(stock_quantity, 5)
purchase_item.quantity_received = 5
purchase_item.order.status = PurchaseOrder.ORDER_CONSIGNED
purchase_item.order.identifier = 334
purchase_item.order.open_date = localdatetime(2012, 1, 1)
purchase_item.order.expected_receival_date = localdatetime(2012, 2, 2)
wizard = CloseInConsignmentWizard(self.store)
step = wizard.get_current_step()
self.click(step.search.search_button)
product_stock_item = self.store.find(ProductStockItem,
storable=storable).one()
self.check_wizard(wizard, 'wizard-return-consignment-selection-step')
order_view = step.search.results[0]
step.search.results.select(order_view)
self.click(wizard.next_button)
step = wizard.get_current_step()
# Select consignment.
step.consignment_items.emit('row_activated', step.consignment_items[0])
self.assertEqual(run_dialog.call_count, 1)
args, kwargs = run_dialog.call_args
editor, parent, store, item = args
self.assertEqual(editor, InConsignmentItemEditor)
self.assertEqual(parent, wizard)
self.assertEqual(item, purchase_item)
self.assertTrue(store is not None)
# Return the total received.
purchase_item.quantity_returned = 5
self.click(wizard.next_button)
# After return. Item quantity in stock must be decreased.
stock_quantity = storable.get_stock_item(branch, None).quantity
self.assertEqual(stock_quantity, 0)
self.check_wizard(wizard,
'wizard-close-returned-in-consignment-confirm',
[wizard.retval, purchase_item, product_stock_item])
示例6: test_complete_receiving_multiple_purchases
def test_complete_receiving_multiple_purchases(self):
branch = api.get_current_branch(self.store)
# Create purchase order 1
product1 = self.create_product(description=u'Product 1', storable=True)
order1 = self.create_purchase_order(branch=branch)
order1.identifier = 10023
order1.open_date = localdatetime(2012, 10, 9)
order1.expected_receival_date = localdatetime(2012, 9, 25)
order1.add_item(product1.sellable, 7)
order1.status = PurchaseOrder.ORDER_PENDING
order1.confirm()
# And purchase order 2
product2 = self.create_product(description=u'Product 2', storable=True)
order2 = self.create_purchase_order(branch=branch,
supplier=order1.supplier)
order2.identifier = 10024
order2.open_date = localdatetime(2012, 10, 9)
order2.expected_receival_date = localdatetime(2012, 9, 25)
order2.add_item(product2.sellable, 5)
order2.status = PurchaseOrder.ORDER_PENDING
order2.confirm()
# Now to the wizard
wizard = ReceivingOrderWizard(self.store)
step = wizard.get_current_step()
self.assertNotSensitive(wizard, ['next_button'])
self.click(step.search.search_button)
# Select both purchase orders. There is one bug in kiwi that we cannot
# select all at once, so thats why we are using this private api.
step.search.results._treeview.get_selection().select_all()
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'receiving-order-multiple-purchase-selection-step')
self.click(wizard.next_button)
step = wizard.get_current_step()
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'receiving-order-multiple-product-step')
self.click(wizard.next_button)
step = wizard.get_current_step()
step.invoice_slave.invoice_number.update(10094)
step.invoice_slave.freight.update(159)
self.check_wizard(wizard, 'receiving-order-multiple-invoice-step')
with contextlib.nested(
mock.patch.object(self.store, 'commit')):
# Confirm
self.click(wizard.next_button)
self.assertEquals(product1.storable.get_balance_for_branch(branch), 7)
self.assertEquals(product2.storable.get_balance_for_branch(branch), 5)
示例7: _create_domain
def _create_domain(self):
client = self.create_client(name=u'Dane Cook')
loan = self.create_loan(client=client)
self.create_loan_item(loan=loan)
loan.identifier = 54952
loan.open_date = localdatetime(2012, 1, 1)
client = self.create_client(name=u'Carmen Sandiego')
loan = self.create_loan(client=client)
self.create_loan_item(loan=loan)
loan.identifier = 45978
loan.open_date = localdatetime(2012, 2, 2)
示例8: testCompleteReceiving
def testCompleteReceiving(self, yesno, run_dialog, warning):
yesno.return_value = True
run_dialog.return_value = Settable(skip=Decimal('0'))
order = self.create_purchase_order()
order.identifier = 65432
order.open_date = localdatetime(2012, 10, 9)
order.expected_receival_date = localdatetime(2012, 9, 25)
sellable = self.create_sellable()
order.add_item(sellable, 1)
order.status = PurchaseOrder.ORDER_PENDING
order.confirm()
wizard = ReceivingOrderWizard(self.store)
step = wizard.get_current_step()
self.assertNotSensitive(wizard, ['next_button'])
self.click(step.search.search_button)
order_view = step.search.results[0]
step.search.results.select(order_view)
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'purchase-selection-step')
self.click(wizard.next_button)
step = wizard.get_current_step()
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'receiving-order-product-step')
self.click(wizard.next_button)
step = wizard.get_current_step()
self.assertNotSensitive(wizard, ['next_button'])
step.invoice_slave.invoice_number.update(1)
self.assertSensitive(wizard, ['next_button'])
self.check_wizard(wizard, 'receiving-invoice-step')
module = 'stoqlib.gui.events.ReceivingOrderWizardFinishEvent.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], ReceivingOrder))
yesno.assert_called_once_with('Do you want to print the labels for '
'the received products?',
gtk.RESPONSE_YES, 'Print labels',
"Don't print")
run_dialog.assert_called_once_with(SkipLabelsEditor, wizard,
self.store)
warning.assert_called_once_with('It was not possible to print the '
'labels. The template file was '
'not found.')
示例9: test_cancel_order_nfce_plugin_active
def test_cancel_order_nfce_plugin_active(self, get_plugin_manager,
run_dialog):
dest_branch = Branch.get_active_remote_branches(self.store)[0]
source_branch = api.get_current_branch(self.store)
order = self.create_transfer_order(source_branch=source_branch,
dest_branch=dest_branch)
self.create_transfer_order_item(order=order)
order.identifier = 28474
order.open_date = localdatetime(2012, 2, 2)
order.send()
dialog = TransferOrderDetailsDialog(self.store, order)
self.assertSensitive(dialog, ['cancel_button'])
get_plugin_manager.is_active.return_value = True
run_dialog.return_value = Note()
with mock.patch.object(self.store, 'commit'):
self.click(dialog.cancel_button)
msg_text = u"This will cancel the transfer. Are you sure?"
run_dialog.assert_called_once_with(
NoteEditor, dialog, order.store, model=None,
message_text=msg_text, label_text=u"Reason", mandatory=True,
ok_button_label=u"Cancel transfer",
cancel_button_label=u"Don't cancel",
min_length=15)
self.assertEqual(order.status, TransferOrder.STATUS_CANCELLED)
self.assertEqual(order.receival_date, None)
示例10: _check_start_step
def _check_start_step(self, uitest=""):
start_step = self.wizard.get_current_step()
start_step.quote_deadline.update(localdatetime(2020, 1, 1))
start_step.quote_group.set_text("12345")
if uitest:
self.check_wizard(self.wizard, uitest)
self.click(self.wizard.next_button)
示例11: test_receive_order
def test_receive_order(self, print_report, yesno):
yesno.retval = True
source_branch = Branch.get_active_remote_branches(self.store)[0]
dest_branch = api.get_current_branch(self.store)
# Created and sent the order.
order = self.create_transfer_order(source_branch=source_branch,
dest_branch=dest_branch)
self.create_transfer_order_item(order=order)
order.identifier = 28474
order.open_date = localdatetime(2012, 2, 2)
order.send()
dialog = TransferOrderDetailsDialog(self.store, order)
self.click(dialog.print_button)
print_report.assert_called_once_with(dialog.report_class, dialog.model)
self.assertSensitive(dialog, ['receive_button'])
with mock.patch.object(self.store, 'commit'):
self.click(dialog.receive_button)
yesno.assert_called_once_with(u'Receive the order?', Gtk.ResponseType.YES,
u'Receive', u"Don't receive")
self.assertEqual(order.status, order.STATUS_RECEIVED)
self.assertEqual(order.cancel_date, None)
示例12: test_undo_with_pending_payment
def test_undo_with_pending_payment(self):
# First, we create a sale_item and relate it to a sale.
sale_item = self.create_sale_item()
sale = sale_item.sale
self.add_payments(sale)
sale.order()
# The sale is then completed and confirmed with its payment confirmed as well.
sale.confirm()
# Now, we create a return adapter to make the actual return.
returned_sale = sale.create_sale_return_adapter()
returned_sale.confirm(self.create_user())
# A pending payment is then made for it to be cancelled when the sale return is
# actually undone.
payment = self.create_payment(date=localdatetime(2012, 1, 1),
value=sale_item.price,
group=sale.group)
payment.set_pending()
# There should be 2 payments at this point.
n_payments1 = sale.payments.count()
returned_sale.undo(reason=u'teste')
# This test evaluates if the pending payment was actually cancelled and that, at
# any point around the undoing of the sale return, no payments are added or
# removed.
self.assertEqual(payment.status, Payment.STATUS_CANCELLED)
self.assertEqual(n_payments1, 2)
self.assertEqual(sale.group.payments.count(), 2)
示例13: create_individual
def create_individual(self, person=None):
from stoqlib.domain.person import Individual, Person
if person is None:
person = Person(name=u'individual', store=self.store)
return Individual(person=person,
birth_date=localdatetime(1970, 1, 1),
store=self.store)
示例14: testCreate
def testCreate(self):
branches = self.store.find(Branch)
dialog = OpenInventoryDialog(self.store, branches)
d = localdatetime(2010, 01, 30, 12, 33)
dialog.open_time.set_text(d.strftime("%X"))
self.check_editor(dialog, 'dialog-open-inventory')
示例15: _create_domain
def _create_domain(self):
self.clean_domain([ReceivingOrderItem, PurchaseReceivingMap, ReceivingOrder])
supplier_a = self.create_supplier(u'Mark')
purchase_order_a = self.create_purchase_order(supplier=supplier_a)
order_a = self.create_receiving_order(purchase_order=purchase_order_a)
supplier_b = self.create_supplier(u'Dominique')
purchase_order_b = self.create_purchase_order(supplier=supplier_b)
order_b = self.create_receiving_order(purchase_order=purchase_order_b)
purchase_order_a.identifier = 81954
order_a.receival_date = localdatetime(2012, 1, 1)
purchase_order_b.identifier = 78526
order_b.receival_date = localdatetime(2012, 2, 2)