-
Notifications
You must be signed in to change notification settings - Fork 71
SAC-30857: Add exclusion for Bulk objects with Suffix #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
satyendra101
wants to merge
4
commits into
master
Choose a base branch
from
SAC-30857-bulk-object-exclusion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
743dbb9
SAC-30857: Add exclusion for new Bulk objects along with documented S…
satyendra101 8486e22
Update base.py to exclude bulk unsupported suffixes
satyendra101 79795c3
Update sfbase.py to exclude suffix objects
satyendra101 104c34c
Address PR comments
satyendra101 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| """ | ||
| Unit tests for Bulk API object exclusion logic introduced to filter objects | ||
| whose names match the *Share, *Feed, *History, or *EventRelation suffixes at | ||
| discovery time, preventing them from being offered to users when they would | ||
| fail at Bulk API prepare-time. | ||
| """ | ||
| import unittest | ||
|
|
||
| from tap_salesforce.salesforce import (UNSUPPORTED_BULK_API_SALESFORCE_OBJECTS, | ||
| Salesforce, is_unsupported_bulk_object) | ||
|
|
||
| START_DATE = "2022-01-01T00:00:00.000000Z" | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Helpers | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def make_sf(api_type="BULK"): | ||
| return Salesforce(default_start_date=START_DATE, api_type=api_type) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Tests for is_unsupported_bulk_object() | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| class TestIsUnsupportedBulkObject(unittest.TestCase): | ||
| """Tests for the is_unsupported_bulk_object helper function.""" | ||
|
|
||
| # --- suffix: Share --- | ||
| def test_share_suffix_standard_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("AccountShare")) | ||
|
|
||
| def test_share_suffix_custom_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("PardotEnvironment__Share")) | ||
|
|
||
| # --- suffix: Feed --- | ||
| def test_feed_suffix_standard_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("CaseFeed")) | ||
|
|
||
| def test_feed_suffix_custom_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("MyObject__Feed")) | ||
|
|
||
| # --- suffix: History --- | ||
| def test_history_suffix_standard_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("ContactHistory")) | ||
|
|
||
| def test_history_suffix_custom_object(self): | ||
| self.assertTrue(is_unsupported_bulk_object("MyObject__History")) | ||
|
|
||
| # --- suffix: EventRelation --- | ||
| def test_eventrelation_suffix_standard(self): | ||
| self.assertTrue(is_unsupported_bulk_object("AcceptedEventRelation")) | ||
|
|
||
| def test_eventrelation_suffix_declined(self): | ||
| self.assertTrue(is_unsupported_bulk_object("DeclinedEventRelation")) | ||
|
|
||
| # --- objects that should NOT be excluded --- | ||
| def test_partial_suffix_match_not_excluded(self): | ||
| # "SharePoint" ends in "Point", not "Share" — must not be excluded | ||
| self.assertFalse(is_unsupported_bulk_object("SharePoint")) | ||
|
|
||
| def test_object_containing_history_not_suffix(self): | ||
| # "HistoryLog" contains "History" but does not end with it | ||
| self.assertFalse(is_unsupported_bulk_object("HistoryLog")) | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Tests for Salesforce.get_blacklisted_objects() — BULK API | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| class TestGetBlacklistedObjectsBulk(unittest.TestCase): | ||
| """get_blacklisted_objects with BULK api_type.""" | ||
|
|
||
| def setUp(self): | ||
| self.sf = make_sf(api_type="BULK") | ||
|
|
||
| def test_suffix_share_object_excluded(self): | ||
| names = ["Account", "AccountShare", "Contact"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("AccountShare", blacklisted) | ||
|
|
||
| def test_suffix_feed_object_excluded(self): | ||
| names = ["Case", "CaseFeed"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("CaseFeed", blacklisted) | ||
|
|
||
| def test_suffix_history_object_excluded(self): | ||
| names = ["Contact", "ContactHistory"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("ContactHistory", blacklisted) | ||
|
|
||
| def test_suffix_eventrelation_object_excluded(self): | ||
| names = ["AcceptedEventRelation", "DeclinedEventRelation", "UndecidedEventRelation"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("AcceptedEventRelation", blacklisted) | ||
| self.assertIn("DeclinedEventRelation", blacklisted) | ||
| self.assertIn("UndecidedEventRelation", blacklisted) | ||
|
|
||
| def test_custom_share_object_excluded(self): | ||
| names = ["PardotEnvironment__Share", "Account"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("PardotEnvironment__Share", blacklisted) | ||
|
|
||
| def test_static_named_objects_excluded(self): | ||
| blacklisted = self.sf.get_blacklisted_objects() | ||
| for obj in UNSUPPORTED_BULK_API_SALESFORCE_OBJECTS: | ||
| self.assertIn(obj, blacklisted) | ||
|
|
||
| def test_supported_objects_not_excluded(self): | ||
| names = ["Account", "Contact", "Opportunity", "Lead"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| for name in names: | ||
| self.assertNotIn(name, blacklisted) | ||
|
|
||
| def test_no_object_names_returns_static_set(self): | ||
| """Without object_names, only static blacklists are returned.""" | ||
| blacklisted_with = self.sf.get_blacklisted_objects(object_names=["AccountShare"]) | ||
| blacklisted_without = self.sf.get_blacklisted_objects() | ||
| # Static entries must be present in both | ||
| self.assertTrue(UNSUPPORTED_BULK_API_SALESFORCE_OBJECTS.issubset(blacklisted_without)) | ||
| # Pattern-matched entry only present when names provided | ||
| self.assertIn("AccountShare", blacklisted_with) | ||
| self.assertNotIn("AccountShare", blacklisted_without) | ||
|
|
||
| def test_object_names_as_set_is_accepted(self): | ||
| """object_names can be passed as a set (not just a list).""" | ||
| names = {"AccountShare", "Contact"} | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertIn("AccountShare", blacklisted) | ||
| self.assertNotIn("Contact", blacklisted) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Tests for Salesforce.get_blacklisted_objects() — REST API | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| class TestGetBlacklistedObjectsRest(unittest.TestCase): | ||
| """get_blacklisted_objects with REST api_type — suffix logic must NOT apply.""" | ||
|
|
||
| def setUp(self): | ||
| self.sf = make_sf(api_type="REST") | ||
|
|
||
| def test_share_suffix_not_excluded_for_rest(self): | ||
| names = ["AccountShare", "Account"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertNotIn("AccountShare", blacklisted) | ||
|
|
||
| def test_feed_suffix_not_excluded_for_rest(self): | ||
| names = ["CaseFeed", "Case"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertNotIn("CaseFeed", blacklisted) | ||
|
|
||
| def test_history_suffix_not_excluded_for_rest(self): | ||
| names = ["ContactHistory"] | ||
| blacklisted = self.sf.get_blacklisted_objects(object_names=names) | ||
| self.assertNotIn("ContactHistory", blacklisted) | ||
|
|
||
| def test_static_bulk_objects_not_in_rest_blacklist(self): | ||
| """Objects in UNSUPPORTED_BULK_API_SALESFORCE_OBJECTS are bulk-only exclusions.""" | ||
| blacklisted = self.sf.get_blacklisted_objects() | ||
| # TaskStatus is bulk-only — it should NOT appear in the REST blacklist | ||
| self.assertNotIn("TaskStatus", blacklisted) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.