Commit 48b9b61f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_*: Fixup Tests

   Unify tests for prevent excessive copy/paste duplication.
parent 1b5f0fba
...@@ -342,7 +342,21 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin): ...@@ -342,7 +342,21 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.tic() self.tic()
current_invoice.Delivery_manageBuildingCalculatingDelivery() current_invoice.Delivery_manageBuildingCalculatingDelivery()
self.tic() self.tic()
current_invoice.SaleInvoiceTransaction_forceBuildSlapOSAccountingLineList() applied_rule = current_invoice.getCausalityRelated(portal_type="Applied Rule")
for sm in self.portal.portal_catalog(portal_type='Simulation Movement',
simulation_state=['draft', 'planned', None],
left_join_list=['delivery_uid'],
delivery_uid=None,
path="%%%s%%" % applied_rule):
if sm.getDelivery() is not None:
continue
root_applied_rule = sm.getRootAppliedRule()
root_applied_rule_path = root_applied_rule.getPath()
sm.getCausalityValue(portal_type='Business Link').build(
path='%s/%%' % root_applied_rule_path)
self.tic() self.tic()
self.login(person.getUserId()) self.login(person.getUserId())
...@@ -632,4 +646,173 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin): ...@@ -632,4 +646,173 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
@withAbort @withAbort
def test_createReversalSaleInvoiceTransaction_wechat_ok_dont_autocancel(self): def test_createReversalSaleInvoiceTransaction_wechat_ok_dont_autocancel(self):
self.test_createReversalSaleInvoiceTransaction_ok_dont_autocancel(payment_mode='wechat') self.test_createReversalSaleInvoiceTransaction_ok_dont_autocancel(payment_mode='wechat')
\ No newline at end of file @withAbort
def test_AccountingTransaction_getPaymentState_draft_payment(self):
invoice = self.createSaleInvoiceTransaction()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_deleted_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.delete()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_cancelled_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.cancel()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_planned_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.plan()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_confirmed_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.setStartDate(DateTime())
invoice.confirm()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_started_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.start()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
@withAbort
def test_AccountingTransaction_getPaymentState_payzen_reversed_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction()
self.tic()
reversal = invoice.SaleInvoiceTransaction_createReversalSaleInvoiceTransaction(
batch_mode=1
)
self.tic()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice())
@withAbort
def test_AccountingTransaction_getPaymentState_wechat_reversed_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(payment_mode='wechat')
self.tic()
reversal = invoice.SaleInvoiceTransaction_createReversalSaleInvoiceTransaction(
batch_mode=1
)
self.tic()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice())
def test_AccountingTransaction_getPaymentState_payzen_free_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(price=0)
self.tic()
self.assertEqual("Free!", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wechat_free_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(price=0, payment_mode='wechat')
self.tic()
self.assertEqual("Free!", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_payzen_unpaid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction()
# If payment is not indexed or not started the state should be Pay Now
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wechat_unpaid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(payment_mode='wechat')
# If payment is not indexed or not started the state should be Pay Now
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_payzen_paynow_payment(self):
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
self.login(person.getUserId())
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wechat_paynow_payment(self):
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl(),
payment_mode="wechat")
self.tic()
self.login(person.getUserId())
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_payzen_waiting_payment(self):
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction",
payment_mode='payzen',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment.PaymentTransaction_generatePayzenId()
self.tic()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wechat_waiting_payment(self):
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl(),
payment_mode='wechat')
payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction",
payment_mode='wechat',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment.PaymentTransaction_generateWechatId()
self.tic()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_payzen_papaid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction()
self.tic()
for line in invoice.getMovementList(self.portal.getPortalAccountingMovementTypeList()):
node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable':
line.setGroupingReference("TEST%s" % self.new_id)
self.assertEqual("Paid",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wechat_paid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(payment_mode='wechat')
self.tic()
for line in invoice.getMovementList(self.portal.getPortalAccountingMovementTypeList()):
node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable':
line.setGroupingReference("TEST%s" % self.new_id)
self.assertEqual("Paid",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_wire_transfer_paid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction(payment_mode='wire_transfer')
self.tic()
for line in invoice.getMovementList(self.portal.getPortalAccountingMovementTypeList()):
node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable':
line.setGroupingReference("TEST%s" % self.new_id)
self.assertEqual("Paid",
invoice.AccountingTransaction_getPaymentState())
def test_Base_getReceivableAccountList(self):
account_list = self.portal.Base_getReceivableAccountList()
self.assertIn('account_module/receivable',
[i.getRelativeUrl() for i in account_list])
\ No newline at end of file
...@@ -557,18 +557,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -557,18 +557,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
payment_list = invoice.getCausalityRelatedValueList( payment_list = invoice.getCausalityRelatedValueList(
portal_type='Payment Transaction') portal_type='Payment Transaction')
self.assertEqual(1, len(payment_list)) self.assertEqual(0, len(payment_list))
payment = payment_list[0].getObject()
causality_list = payment.getCausalityValueList()
self.assertSameSet([invoice], causality_list)
self.assertEqual('started', payment.getSimulationState())
self.assertEqual('draft', payment.getCausalityState())
self.assertEqual(-1 * payment.PaymentTransaction_getTotalPayablePrice(),
invoice.getTotalPrice())
def assertPersonDocumentCoverage(self, person): def assertPersonDocumentCoverage(self, person):
self.login() self.login()
...@@ -672,6 +661,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -672,6 +661,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertInvoiceNotification(person, is_email_expected) self.assertInvoiceNotification(person, is_email_expected)
invoice_list = person.Entity_getOutstandingAmountList() invoice_list = person.Entity_getOutstandingAmountList()
self.login()
if subscription_request is not None: if subscription_request is not None:
expected_causality = subscription_request.getRelativeUrl() expected_causality = subscription_request.getRelativeUrl()
filtered_invoice_list = [] filtered_invoice_list = []
...@@ -685,6 +676,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -685,6 +676,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
else: else:
self.assertEqual(len(invoice_list), 1) self.assertEqual(len(invoice_list), 1)
self.login(user_id)
document_id = invoice_list[0].getId() document_id = invoice_list[0].getId()
web_site.accounting_module[document_id].\ web_site.accounting_module[document_id].\
SaleInvoiceTransaction_redirectToManualSlapOSPayment() SaleInvoiceTransaction_redirectToManualSlapOSPayment()
......
...@@ -567,13 +567,13 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -567,13 +567,13 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
reference="TESTTRANS-%s" % new_id, reference="TESTTRANS-%s" % new_id,
) )
def createSaleInvoiceTransaction(self): def createSaleInvoiceTransaction(self, **kw):
new_id = self.generateNewId() new_id = self.generateNewId()
return self.portal.accounting_module.newContent( return self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
title="Invoice %s" % new_id, title="Invoice %s" % new_id,
reference="TESTSIT-%s" % new_id, reference="TESTSIT-%s" % new_id,
) **kw)
def createPayzenEvent(self): def createPayzenEvent(self):
return self.portal.system_event_module.newContent( return self.portal.system_event_module.newContent(
...@@ -585,16 +585,11 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -585,16 +585,11 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
portal_type='Wechat Event', portal_type='Wechat Event',
reference='PAY-%s' % self.generateNewId()) reference='PAY-%s' % self.generateNewId())
def createPayzenSaleInvoiceTransaction(self, destination_section=None, price=2, payment_mode="payzen"): def createStoppedSaleInvoiceTransaction(self, destination_section=None, price=2, payment_mode="payzen"):
new_title = self.generateNewId()
new_reference = self.generateNewId()
new_source_reference = self.generateNewId() new_source_reference = self.generateNewId()
new_destination_reference = self.generateNewId() new_destination_reference = self.generateNewId()
invoice = self.portal.accounting_module.newContent( invoice = self.createSaleInvoiceTransaction(
portal_type="Sale Invoice Transaction",
title=new_title,
start_date=DateTime(), start_date=DateTime(),
reference=new_reference,
source_reference=new_source_reference, source_reference=new_source_reference,
destination_reference=new_destination_reference, destination_reference=new_destination_reference,
destination_section=destination_section, destination_section=destination_section,
...@@ -616,12 +611,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -616,12 +611,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
) )
return invoice return invoice
def createWechatSaleInvoiceTransaction(self, destination_section=None, price=2):
return self.createPayzenSaleInvoiceTransaction(destination_section=destination_section,
price=price,
payment_mode='wechat')
def createRegularisationRequest(self): def createRegularisationRequest(self):
new_id = self.generateNewId() new_id = self.generateNewId()
return self.portal.regularisation_request_module.newContent( return self.portal.regularisation_request_module.newContent(
......
...@@ -280,6 +280,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): ...@@ -280,6 +280,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
default_source_project_uid=person.getUid() default_source_project_uid=person.getUid()
) )
self.assertNotEqual(ticket, None)
event = self.portal.portal_catalog.getResultValue( event = self.portal.portal_catalog.getResultValue(
portal_type='Mail Message', portal_type='Mail Message',
default_resource_uid=self.portal.service_module[service_id].getUid(), default_resource_uid=self.portal.service_module[service_id].getUid(),
...@@ -341,18 +342,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): ...@@ -341,18 +342,7 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
payment_list = invoice.getCausalityRelatedValueList( payment_list = invoice.getCausalityRelatedValueList(
portal_type='Payment Transaction') portal_type='Payment Transaction')
self.assertEqual(1, len(payment_list)) self.assertEqual(0, len(payment_list))
payment = payment_list[0].getObject()
causality_list = payment.getCausalityValueList()
self.assertSameSet([invoice], causality_list)
self.assertEqual('cancelled', payment.getSimulationState())
self.assertEqual('draft', payment.getCausalityState())
self.assertEqual(-1 * payment.PaymentTransaction_getTotalPayablePrice(),
invoice.getTotalPrice())
# Check reverse invoice # Check reverse invoice
reverse_invoice_list = invoice.getCausalityRelatedValueList( reverse_invoice_list = invoice.getCausalityRelatedValueList(
......
...@@ -45,14 +45,6 @@ class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort): ...@@ -45,14 +45,6 @@ class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbort): class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbort):
def createPaymentTransaction(self):
new_id = self.generateNewId()
return self.portal.accounting_module.newContent(
portal_type='Payment Transaction',
title="Transaction %s" % new_id,
reference="TESTTRANS-%s" % new_id,
)
def test_date_changed(self): def test_date_changed(self):
date = DateTime("2001/01/01") date = DateTime("2001/01/01")
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -677,85 +669,6 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAb ...@@ -677,85 +669,6 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAb
result = self.portal.Base_getPayzenServiceRelativeUrl() result = self.portal.Base_getPayzenServiceRelativeUrl()
self.assertEqual(result, 'portal_secure_payments/slapos_payzen_test') self.assertEqual(result, 'portal_secure_payments/slapos_payzen_test')
class TestSlapOSPayzenAccountingTransaction_getPaymentState(
SlapOSTestCaseMixinWithAbort):
def test_AccountingTransaction_getPaymentState_draft_payment(self):
invoice = self.createSaleInvoiceTransaction()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_deleted_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.delete()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_cancelled_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.cancel()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_planned_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.plan()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_confirmed_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.setStartDate(DateTime())
invoice.confirm()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_started_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.start()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_reversed_payment(self):
invoice = self.createPayzenSaleInvoiceTransaction()
self.tic()
reversal = invoice.SaleInvoiceTransaction_createReversalSaleInvoiceTransaction()
self.tic()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice())
def test_AccountingTransaction_getPaymentState_free_payment(self):
invoice = self.createPayzenSaleInvoiceTransaction(price=0)
self.tic()
self.assertEqual("Free!", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_unpaid_payment(self):
invoice = self.createPayzenSaleInvoiceTransaction()
# If payment is not indexed or not started the state should be unpaid
self.assertEqual("Unpaid", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_paynow_payment(self):
person = self.makePerson()
invoice = self.createPayzenSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
self.login(person.getUserId())
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_waiting_payment(self):
person = self.makePerson()
invoice = self.createPayzenSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
payment = invoice.SaleInvoiceTransaction_getSlapOSPaymentRelatedValue()
payment.PaymentTransaction_generatePayzenId()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_paid_payment(self):
invoice = self.createPayzenSaleInvoiceTransaction()
self.tic()
for line in invoice.getMovementList(self.portal.getPortalAccountingMovementTypeList()):
node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable':
line.setGroupingReference("TEST%s" % self.new_id)
self.assertEqual("Paid", invoice.AccountingTransaction_getPaymentState())
class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment( class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment(
SlapOSTestCaseMixinWithAbort): SlapOSTestCaseMixinWithAbort):
...@@ -800,11 +713,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -800,11 +713,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self): def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self):
person = self.makePerson() person = self.makePerson()
invoice = self.createPayzenSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
self.tic() self.tic()
payment = invoice.SaleInvoiceTransaction_getSlapOSPaymentRelatedValue() payment = self.portal.accounting_module.newContent(
payment.setResourceValue(self.portal.currency_module.EUR) portal_type="Payment Transaction",
payment_mode='payzen',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
resource_value=self.portal.currency_module.EUR,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
self.tic() self.tic()
self.login(person.getUserId()) self.login(person.getUserId())
self._simulatePaymentTransaction_getVADSUrlDict() self._simulatePaymentTransaction_getVADSUrlDict()
...@@ -830,15 +751,32 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -830,15 +751,32 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
"%s/return" % (payment_transaction_url)]: "%s/return" % (payment_transaction_url)]:
self.assertTrue(item in text_content, self.assertTrue(item in text_content,
"%s not in %s" % (item, text_content)) "%s not in %s" % (item, text_content))
self.tic()
system_event_list = payment.getDestinationRelatedValueList(portal_type="Payzen Event")
self.assertEqual(len(system_event_list), 1)
self.assertEqual(
system_event_list[0].getDestinationSection(),
invoice.getDestinationSection())
self.assertEqual(
len(system_event_list[0].contentValues(portal_type="Payzen Event Message")), 1)
def test_PaymentTransaction_redirectToManualPayzenPayment_already_registered(self): def test_PaymentTransaction_redirectToManualPayzenPayment_already_registered(self):
person = self.makePerson() person = self.makePerson()
invoice = self.createPayzenSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
self.tic() self.tic()
payment = invoice.SaleInvoiceTransaction_getSlapOSPaymentRelatedValue() payment = self.portal.accounting_module.newContent(
payment.setResourceValue(self.portal.currency_module.EUR) portal_type="Payment Transaction",
payment_mode='payzen',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
resource_value=self.portal.currency_module.EUR,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment.PaymentTransaction_generatePayzenId() payment.PaymentTransaction_generatePayzenId()
self.tic() self.tic()
self.login(person.getUserId()) self.login(person.getUserId())
...@@ -850,3 +788,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -850,3 +788,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self.assertEqual("%s/already_registered" % payment.getRelativeUrl(), self.assertEqual("%s/already_registered" % payment.getRelativeUrl(),
redirect) redirect)
system_event_list = payment.getDestinationRelatedValueList(portal_type="Payzen Event")
self.assertEqual(len(system_event_list), 0)
\ No newline at end of file
...@@ -534,85 +534,6 @@ class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAb ...@@ -534,85 +534,6 @@ class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAb
result = self.portal.Base_getWechatServiceRelativeUrl() result = self.portal.Base_getWechatServiceRelativeUrl()
self.assertEqual(result, 'portal_secure_payments/slapos_wechat_test') self.assertEqual(result, 'portal_secure_payments/slapos_wechat_test')
class TestSlapOSWechatAccountingTransaction_getPaymentState(
SlapOSTestCaseMixinWithAbort):
def test_AccountingTransaction_getPaymentState_draft_payment(self):
invoice = self.createSaleInvoiceTransaction()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_deleted_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.delete()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_cancelled_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.cancel()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_planned_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.plan()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_confirmed_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.setStartDate(DateTime())
invoice.confirm()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_started_payment(self):
invoice = self.createSaleInvoiceTransaction()
invoice.start()
self.assertEqual("Ongoing", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_reversed_payment(self):
invoice = self.createWechatSaleInvoiceTransaction()
self.tic()
reversal = invoice.SaleInvoiceTransaction_createReversalWechatTransaction()
self.tic()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice())
def test_AccountingTransaction_getPaymentState_free_payment(self):
invoice = self.createWechatSaleInvoiceTransaction(price=0)
self.tic()
self.assertEqual("Free!", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_unpaid_payment(self):
invoice = self.createWechatSaleInvoiceTransaction()
# If payment is not indexed or not started the state should be unpaid
self.assertEqual("Unpaid", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_paynow_payment(self):
person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
self.login(person.getUserId())
self.assertEqual("Pay Now", invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_waiting_payment(self):
person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
payment = invoice.SaleInvoiceTransaction_getWechatPaymentRelatedValue()
payment.PaymentTransaction_generateWechatId()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
invoice.AccountingTransaction_getPaymentState())
def test_AccountingTransaction_getPaymentState_paid_payment(self):
invoice = self.createWechatSaleInvoiceTransaction()
self.tic()
for line in invoice.getMovementList(self.portal.getPortalAccountingMovementTypeList()):
node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable':
line.setGroupingReference("TEST%s" % self.new_id)
self.assertEqual("Paid", invoice.AccountingTransaction_getPaymentState())
class TestSlapOSWechatPaymentTransaction_redirectToManualWechatPayment( class TestSlapOSWechatPaymentTransaction_redirectToManualWechatPayment(
SlapOSTestCaseMixinWithAbort): SlapOSTestCaseMixinWithAbort):
...@@ -657,11 +578,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -657,11 +578,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self): def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self):
person = self.makePerson() person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
self.tic() self.tic()
payment = invoice.SaleInvoiceTransaction_getWechatPaymentRelatedValue() payment = self.portal.accounting_module.newContent(
payment.setResourceValue(self.portal.currency_module.EUR) portal_type="Payment Transaction",
payment_mode='wechat',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
resource_value=self.portal.currency_module.CNY,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment_transaction_id = payment.getId() payment_transaction_id = payment.getId()
self.tic() self.tic()
...@@ -693,11 +622,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -693,11 +622,19 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self): def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
person = self.makePerson() person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
self.tic() self.tic()
payment = invoice.SaleInvoiceTransaction_getWechatPaymentRelatedValue() payment = self.portal.accounting_module.newContent(
payment.setResourceValue(self.portal.currency_module.EUR) portal_type="Payment Transaction",
payment_mode='wechat',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
resource_value=self.portal.currency_module.CNY,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment_transaction_id = payment.getId() payment_transaction_id = payment.getId()
web_site = self.portal.web_site_module.newContent(portal_type='Web Site') web_site = self.portal.web_site_module.newContent(portal_type='Web Site')
...@@ -725,11 +662,20 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -725,11 +662,20 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self): def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self):
person = self.makePerson() person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section=person.getRelativeUrl())
self.tic() self.tic()
payment = invoice.SaleInvoiceTransaction_getWechatPaymentRelatedValue() payment = self.portal.accounting_module.newContent(
payment.setResourceValue(self.portal.currency_module.EUR) portal_type="Payment Transaction",
payment_mode='wechat',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
resource_value=self.portal.currency_module.CNY,
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment.PaymentTransaction_generateWechatId() payment.PaymentTransaction_generateWechatId()
self.tic() self.tic()
self.login(person.getUserId()) self.login(person.getUserId())
...@@ -740,4 +686,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -740,4 +686,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self._dropPaymentTransaction_getVADSUrlDict() self._dropPaymentTransaction_getVADSUrlDict()
self.assertEqual("%s/already_registered" % payment.getRelativeUrl(), self.assertEqual("%s/already_registered" % payment.getRelativeUrl(),
redirect) redirect)
\ No newline at end of file
system_event_list = payment.getDestinationRelatedValueList(portal_type="Payzen Event")
self.assertEqual(len(system_event_list), 0)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment