Skip to content
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

Implement all_fields test using new framework-tdl-7499 #159

Merged
merged 32 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2f55a8e
Implement all_fields test using new framework-tdl-7499
bhuvana-talend Jun 8, 2023
c2366e5
Added couple of methods for table_reset test
bhuvana-talend Jun 13, 2023
86bed57
Merge branch 'master' into tdl-7499
bhuvana-talend Jun 16, 2023
be7de62
Removed the conflicts
bhuvana-talend Jul 17, 2023
f73479c
Merge branch 'master' into tdl-7499
bhuvana-talend Jul 17, 2023
410d972
Added comments for future work
bhuvana-talend Jul 21, 2023
8d48a2d
added comments
bhuvana-talend Jul 21, 2023
b576c02
Test if custom fields are replicated fine
bhuvana-talend Jul 25, 2023
e6ed1a0
Test if non custom fields are replicated fine
bhuvana-talend Jul 25, 2023
3b928f8
Added custom_fields and non_custom_fields and method to select stream…
bhuvana-talend Jul 26, 2023
8370c1d
Renamed the testfiles for custom and non-custom fields tests
bhuvana-talend Jul 26, 2023
683f332
Added comments for the todo tests
bhuvana-talend Jul 26, 2023
33ca793
Renamed to different filename
bhuvana-talend Jul 26, 2023
5e1bf83
Removed as custom and non-custom fields are split to separate testfiles
bhuvana-talend Jul 26, 2023
ab06d29
Added comment for future work for custom and non-custom fields
bhuvana-talend Aug 7, 2023
a5481e3
override test_all_fields_for_streams_are_replicated to exclude automa…
bhuvana-talend Aug 7, 2023
409f816
Use automatic fields instead of hardcoding
bhuvana-talend Aug 7, 2023
34c2458
Implemented PR Review changes to remove the overriden method and add …
bhuvana-talend Aug 17, 2023
9776995
New method to count custom and non-custom fields from replicated fields
bhuvana-talend Aug 29, 2023
23a0816
Get the count of custom and non-custom fields and assert
bhuvana-talend Aug 29, 2023
ab4f841
Merge branch 'master' into tdl-7499
bhtowles Sep 6, 2023
8e6b8d4
Removed blank spaces around paranthesis
bhuvana-talend Sep 7, 2023
89f629a
Merge branch 'tdl-7499' of github.com:singer-io/tap-salesforce into t…
bhuvana-talend Sep 7, 2023
390660b
Merge branch 'master' into tdl-7499
JYOTHINARAYANSETTY Sep 12, 2023
cac3542
Changed the assertions
bhuvana-talend Sep 15, 2023
9815beb
Merge branch 'tdl-7499' of github.com:singer-io/tap-salesforce into t…
bhuvana-talend Sep 15, 2023
8d4caad
fixed assertions
bhuvana-talend Sep 15, 2023
724f1d5
tdl-23781,23563,23654
JYOTHINARAYANSETTY Oct 3, 2023
ae0f9a9
Add new tests
JYOTHINARAYANSETTY Oct 3, 2023
0c5127b
resolving merge conflicts
JYOTHINARAYANSETTY Oct 3, 2023
b662005
review changes
JYOTHINARAYANSETTY Oct 4, 2023
4a903b0
move streams_to test method to base class
JYOTHINARAYANSETTY Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/sfbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ class SFBaseTest(BaseCase):

salesforce_api = "BULK"

#TODO - TDL-23781: [tap-salesforce] QA: Get Custom fields and non-custom fields
custom_fields = {"Account": {'SLAExpirationDate__c', 'SLASerialNumber__c', 'UpsellOpportunity__c', 'CustomerPriority__c', 'NumberofLocations__c', 'Active__c', 'SLA__c'},
'Contact': {'Languages__c', 'Level__c'}
}

non_custom_fields = {"Account": {'Description', 'BillingCountry', 'ParentId', 'Name', 'CleanStatus', 'ShippingStreet', 'IsDeleted', 'Jigsaw', 'BillingPostalCode', 'TickerSymbol', 'Fax', 'AccountSource', 'MasterRecordId', 'JigsawCompanyId', 'PhotoUrl', 'Rating', 'Tradestyle', 'Id', 'ShippingLatitude', 'CreatedById', 'CreatedDate', 'Website', 'ShippingPostalCode', 'ShippingState', 'OperatingHoursId', 'BillingLatitude', 'LastViewedDate', 'ShippingGeocodeAccuracy', 'LastReferencedDate', 'Ownership', 'NumberOfEmployees', 'DunsNumber', 'LastActivityDate', 'NaicsDesc', 'Sic', 'ShippingCity', 'ShippingLongitude', 'BillingGeocodeAccuracy', 'SicDesc', 'SystemModstamp', 'Type', 'Industry', 'BillingState', 'BillingStreet', 'BillingCity', 'YearStarted', 'DandbCompanyId', 'OwnerId', 'Site', 'LastModifiedDate', 'ShippingCountry', 'AnnualRevenue', 'AccountNumber', 'LastModifiedById', 'Phone', 'NaicsCode', 'BillingLongitude'},
bhtowles marked this conversation as resolved.
Show resolved Hide resolved
"Contact": {'Description', 'EmailBouncedDate', 'LastCUUpdateDate', 'Email', 'MailingCity', 'OtherPhone', 'MailingStreet', 'Name', 'OtherCountry', 'CleanStatus', 'IsDeleted', 'Title', 'FirstName', 'Department', 'Jigsaw', 'Salutation', 'MailingCountry', 'OtherPostalCode', 'MobilePhone', 'Fax', 'MasterRecordId', 'PhotoUrl', 'OtherStreet', 'Id', 'OtherLongitude', 'MailingLatitude', 'LastName', 'CreatedById', 'OtherCity', 'CreatedDate', 'JigsawContactId', 'AccountId', 'LastViewedDate', 'AssistantPhone', 'LastCURequestDate', 'LastReferencedDate', 'OtherLatitude', 'LastActivityDate', 'LeadSource', 'EmailBouncedReason', 'SystemModstamp', 'OtherGeocodeAccuracy', 'OtherState', 'HomePhone', 'AssistantName', 'MailingGeocodeAccuracy', 'MailingState', 'IndividualId', 'IsEmailBounced', 'MailingPostalCode', 'OwnerId', 'LastModifiedDate', 'ReportsToId', 'MailingLongitude', 'Birthdate', 'LastModifiedById', 'Phone'} }

@staticmethod
def tap_name():
"""The name of the tap"""
Expand Down Expand Up @@ -844,6 +852,14 @@ def rest_only_streams(self):
'UndecidedEventRelation',
}

def expected_streams(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these self references may have to change to cls references for some of the methods according to recent changes in sfbase.

"""A set of expected stream names"""
streams = set(self.expected_metadata().keys())

if self.salesforce_api == 'BULK':
return streams.difference(self.rest_only_streams())
return streams

def set_replication_methods(self, conn_id, catalogs, replication_methods):

replication_keys = self.expected_replication_keys()
Expand Down
47 changes: 47 additions & 0 deletions tests/test_salesforce_all_fields_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Test that with only custom fields selected for a stream automatic fields and custom fields are still replicated
"""
import copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused

from tap_tester.base_suite_tests.all_fields_test import AllFieldsTest
from sfbase import SFBaseTest
from tap_tester.logger import LOGGER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused



class SFCustomFieldsTest(AllFieldsTest, SFBaseTest):
"""Test that with only custom fields selected for a stream automatic fields and custom fields are still replicated
TODO
This test coveres only BULK api and just couple of streams. We have separate cards to cover these cases
TDL-23653: [tap-salesforce]: QA - Add all the streams for the all_fields test
TDL-23654: [tap-salesforce]: QA - Add all-fields testcase for REST API streams
"""

salesforce_api = 'BULK'

@staticmethod
def name():
return "tt_sf_all_fields_custom"

def streams_to_test(self):
streams = {'Account', 'Contact'}
return streams

@staticmethod
def streams_to_selected_fields():
return SFBaseTest.custom_fields

def test_custom_fields( self ):
for stream in self.streams_to_selected_fields():
expected_custom_fields = self.streams_to_selected_fields().get(stream, set() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_custom_fields = self.streams_to_selected_fields().get(stream, set() )
expected_custom_fields = self.streams_to_selected_fields().get(stream, set())

replicated_custom_fields = self.actual_fields.get(stream, set() ).difference(self.expected_automatic_fields(stream))

#Verify at least one custom field is replicated
self.assertIsNotNone( replicated_custom_fields, msg = f"Replication didn't return any custom fields for stream {stream}" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIsNotNone( replicated_custom_fields, msg = f"Replication didn't return any custom fields for stream {stream}" )
self.assertIsNotNone(replicated_custom_fields, msg = f"Replication didn't return any custom fields for stream {stream}")


#Verify only custom fields are replicated by checking the field name
self.assertTrue( self.verify_custom_fields( replicated_custom_fields ), "Replicated some fields that are not custom fields for stream {stream}" )

"""
TODO: Add this assertion when we do
TDL-23781: [tap-salesforce] QA: Get Custom fields and non-custom fields
self.assertIsNone(replicated_custom_fields.difference(automatic_fields))
"""
47 changes: 47 additions & 0 deletions tests/test_salesforce_all_fields_non_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Test that with only non-custom fields selected for a stream automatic fields and non custom fields are still replicated
"""

from tap_tester.base_suite_tests.all_fields_test import AllFieldsTest
from sfbase import SFBaseTest


class SFNonCustomFieldsTest(AllFieldsTest, SFBaseTest):
"""Test that with only non-custom fields selected for a stream automatic fields and non custom fields are still replicated
TODO
This test coveres only BULK api and just couple of streams. We have separate cards to cover these cases
TDL-23653: [tap-salesforce]: QA - Add all the streams for the all_fields test
TDL-23654: [tap-salesforce]: QA - Add all-fields testcase for REST API streams
"""

salesforce_api = 'BULK'

@staticmethod
def name():
return "tt_sf_all_fields_non_custom"

def streams_to_test(self):
streams = {'Account', 'Contact'}
return streams

@staticmethod
def streams_to_selected_fields():
return SFBaseTest.non_custom_fields

def test_non_custom_fields( self ):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_non_custom_fields( self ):
def test_non_custom_fields(self):

for stream in self.streams_to_selected_fields():
expected_non_custom_fields = self.streams_to_selected_fields().get(stream, set() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_non_custom_fields = self.streams_to_selected_fields().get(stream, set() )
expected_non_custom_fields = self.streams_to_selected_fields().get(stream, set())

replicated_non_custom_fields = self.actual_fields.get(stream, set() ).difference(self.expected_automatic_fields(stream))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to subtract automatic fields here because the automatic fields are non custom fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to subtract automatic fields - if the replicated fields contain only automatic fields, my assertion for Not none in the next line will not verify if fields other than automatic fields are replicated or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The automatic fields are non custom fields. The test is currently making a sub-set of non_custom fields. Do we need to track both groups? All non custom fields and then all non custom fields that aren't automatic? I'm not sure we need to do this. We could have two assertions if you want to check both cases:
self.assertIsNotNone(replicated_non_custom_fields, msg)
self.assertIsNotNone(replicated_non_custom_fields.difference(self.expected_automatic_fields(stream)), msg)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the test that is still failing. I suggest not removing automatic fields from replicated_non_custom_fields. Then we can add two more assertions

  1. The first assertion to make sure that the count of non custom fields is greater than the count of automatic fields to make sure that we are replicating more than just the automatic fields.
  2. To make sure the number of non custom fields is equal to the number of replicated fields to make sure we didn't miss any.


#Verify at least one non-custom field is replicated
self.assertIsNotNone( replicated_non_custom_fields, msg = f"Replication didn't return any non-custom fields for stream {stream}" )
bhtowles marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIsNotNone( replicated_non_custom_fields, msg = f"Replication didn't return any non-custom fields for stream {stream}" )
self.assertIsNotNone(replicated_non_custom_fields, msg = f"Replication didn't return any non-custom fields for stream {stream}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertIsNotNone( replicated_non_custom_fields, msg = f"Replication didn't return any non-custom fields for stream {stream}" )
self.assertIsNotNone(replicated_non_custom_fields, msg = f"Replication didn't return any non-custom fields for stream {stream}")


#Verify ustom fields are not replicated by checking the field name
self.assertFalse( self.verify_custom_fields( replicated_non_custom_fields ), "Replicated some fields that are custom fields for stream {stream}" )
bhtowles marked this conversation as resolved.
Show resolved Hide resolved


"""
TODO: Add this assertion when we do
TDL-23781: [tap-salesforce] QA: Get Custom fields and non-custom fields
self.assertIsNone(replicated_custom_fields.difference(automatic_fields))
"""