Commit d5107927 authored by Yusei Tahara's avatar Yusei Tahara

Test if subdocuments are reindexed when trade condition is modified.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35329 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b480b01c
...@@ -96,6 +96,95 @@ class TradeConditionTestCase(ERP5TypeTestCase): ...@@ -96,6 +96,95 @@ class TradeConditionTestCase(ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
def test_subcontent_supply_line_reindexing(self):
# If trade condition is modified, then supply lines must be reindexed
another_resource = self.portal.product_module.newContent(portal_type='Product',
title='Another Resource')
# Supply lines are made without source_section and destination_section
supply_line_1 = self.trade_condition.newContent(portal_type=self.supply_line_type,
resource_value=self.resource)
supply_line_2 = self.trade_condition.newContent(portal_type=self.supply_line_type,
resource_value=another_resource)
transaction.commit()
self.tic()
# Set source_section and destination_section to trade condition
# Then recursive reindex should be called
self.trade_condition.edit(source_section_value=self.client,
destination_section_value=self.vendor)
transaction.commit()
self.tic()
# New indexes have source_section, destination_section
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.trade_condition_type,
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
1)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=another_resource.getRelativeUrl(),
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
1)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=self.resource.getRelativeUrl(),
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
1)
# Change source_section and destination_section
company_a = self.portal.organisation_module.newContent(portal_type='Organisation',
title='Company A')
company_b = self.portal.organisation_module.newContent(portal_type='Organisation',
title='Company B')
transaction.commit()
self.tic()
# When edit, recursive reindex should be called
self.trade_condition.edit(source_section_value=None,
destination_section_value=None,
source_value=company_a,
destination_value=company_b)
transaction.commit()
self.tic()
# No old indexes
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.trade_condition_type,
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
0)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=self.resource.getRelativeUrl(),
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
0)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=another_resource.getRelativeUrl(),
source_section_relative_url=self.client.getRelativeUrl(),
destination_section_relative_url=self.vendor.getRelativeUrl())),
0)
# New indexes
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.trade_condition_type,
source_relative_url=company_a.getRelativeUrl(),
destination_relative_url=company_b.getRelativeUrl())),
1)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=self.resource.getRelativeUrl(),
source_relative_url=company_a.getRelativeUrl(),
destination_relative_url=company_b.getRelativeUrl())),
1)
self.assertEqual(len(self.portal.portal_catalog(portal_type=self.supply_line_type,
resource_relative_url=another_resource.getRelativeUrl(),
source_relative_url=company_a.getRelativeUrl(),
destination_relative_url=company_b.getRelativeUrl())),
1)
class AccountingBuildTestCase(TradeConditionTestCase): class AccountingBuildTestCase(TradeConditionTestCase):
"""Same as TradeConditionTestCase, but with a rule to generate """Same as TradeConditionTestCase, but with a rule to generate
......
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