Skip to content

Commit

Permalink
* refactor integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RushiT0122 committed Jan 9, 2025
1 parent d34f3d1 commit 7ad5e8b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 64 deletions.
25 changes: 14 additions & 11 deletions tests/test_facebook_all_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test that with no fields selected for a stream all fields are still replicated
"""

from tap_tester import LOGGER
from tap_tester.base_suite_tests.all_fields_test import AllFieldsTest
from base_new_frmwrk import FacebookBaseTest
import base
Expand Down Expand Up @@ -224,15 +225,17 @@ def name():
return "tt_facebook_all_fields_test"

def streams_to_test(self):
# return set(self.expected_metadata().keys())
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
if self.is_done is None:
self.is_done = base.JIRA_CLIENT.get_status_category("TDL-24312") == 'done'
self.assert_message = ("JIRA ticket has moved to done, re-add the "
"applicable EXCLUDE_STREAMS to the test.")
self.is_done_2 = base.JIRA_CLIENT.get_status_category("TDL-26640") == 'done'
# if either card is done, fail & update the test to include more streams
self.is_done = self.is_done or self.is_done_2
assert self.is_done != True, self.assert_message
exprected_streams = self.expected_metadata().keys()
self.assert_message = f"JIRA ticket has moved to done, \
re-add the applicable stream to the test: {0}"
assert base.JIRA_CLIENT.get_status_category("TDL-24312") != 'done',\
self.assert_message.format('ads_insights_hourly_advertiser')
exprected_streams = self.expected_metadata().keys() - {'ads_insights_hourly_advertiser'}
LOGGER.warn(f"Skipped streams: {'ads_insights_hourly_advertiser'}")

return self.expected_metadata().keys() - self.EXCLUDE_STREAMS
assert base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done',\
self.assert_message.format(self.EXCLUDE_STREAMS)
exprected_streams = self.expected_metadata().keys() - self.EXCLUDE_STREAMS
LOGGER.warn(f"Skipped streams: {self.EXCLUDE_STREAMS}")

return exprected_streams
7 changes: 2 additions & 5 deletions tests/test_facebook_attribution_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ def get_properties(self, original: bool = True):
return_value["start_date"] = self.start_date
return return_value

# TODO: https://jira.talendforge.org/browse/TDL-26640
@base.skipUnless(base.JIRA_CLIENT.get_status_category("TDL-26640") == "done", "TDL-26640")
def test_run(self):
"""
For the test ad set up in facebook ads manager we see data
on April 7th, start date is based on this data
"""
# TODO: https://jira.talendforge.org/browse/TDL-26640
if base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done':
LOGGER.warning("Skipping TEST! See BUG[TDL-26640]")
self.skipTest("Skipping TEST! See BUG[TDL-26640]")

# attrribution window = 7
self.ATTRIBUTION_WINDOW = 7
self.start_date = '2021-04-14T00:00:00Z'
Expand Down
28 changes: 15 additions & 13 deletions tests/test_facebook_automatic_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import os

from tap_tester import runner, connections
from tap_tester import runner, connections, LOGGER
import base
from base import FacebookBaseTest

Expand All @@ -29,18 +29,20 @@ def name():
return "tap_tester_facebook_automatic_fields"

def streams_to_test(self):
# return set(self.expected_metadata().keys())
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
if self.is_done is None:
self.is_done = base.JIRA_CLIENT.get_status_category("TDL-24312") == 'done'
self.assert_message = ("JIRA ticket has moved to done, re-add the "
"applicable EXCLUDE_STREAMS to the test.")
self.is_done_2 = base.JIRA_CLIENT.get_status_category("TDL-26640") == 'done'
# if either card is done, fail & update the test to include more streams
self.is_done = self.is_done or self.is_done_2
assert self.is_done != True, self.assert_message

return self.expected_metadata().keys() - self.EXCLUDE_STREAMS
exprected_streams = self.expected_metadata().keys()
self.assert_message = f"JIRA ticket has moved to done, \
re-add the applicable stream to the test: {0}"
assert base.JIRA_CLIENT.get_status_category("TDL-24312") != 'done',\
self.assert_message.format('ads_insights_hourly_advertiser')
exprected_streams = self.expected_metadata().keys() - {'ads_insights_hourly_advertiser'}
LOGGER.warn(f"Skipped streams: {'ads_insights_hourly_advertiser'}")

assert base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done',\
self.assert_message.format(self.EXCLUDE_STREAMS)
exprected_streams = self.expected_metadata().keys() - self.EXCLUDE_STREAMS
LOGGER.warn(f"Skipped streams: {self.EXCLUDE_STREAMS}")

return exprected_streams

def get_properties(self, original: bool = True):
"""Configuration properties required for the tap."""
Expand Down
27 changes: 15 additions & 12 deletions tests/test_facebook_bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import pytz

from tap_tester import runner, menagerie, connections
from tap_tester import runner, menagerie, connections, LOGGER

from base import FacebookBaseTest

Expand All @@ -29,17 +29,20 @@ def name():
return "tap_tester_facebook_bookmarks"

def streams_to_test(self):
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
if self.is_done is None:
self.is_done = base.JIRA_CLIENT.get_status_category("TDL-24312") == 'done'
self.assert_message = ("JIRA ticket has moved to done, re-add the "
"applicable EXCLUDE_STREAMS to the test.")
self.is_done_2 = base.JIRA_CLIENT.get_status_category("TDL-26640") == 'done'
# if either card is done, fail & update the test to include more streams
self.is_done = self.is_done or self.is_done_2
assert self.is_done != True, self.assert_message

return self.expected_streams() - self.EXCLUDE_STREAMS
exprected_streams = self.expected_metadata().keys()
self.assert_message = f"JIRA ticket has moved to done, \
re-add the applicable stream to the test: {0}"
assert base.JIRA_CLIENT.get_status_category("TDL-24312") != 'done',\
self.assert_message.format('ads_insights_hourly_advertiser')
exprected_streams = self.expected_metadata().keys() - {'ads_insights_hourly_advertiser'}
LOGGER.warn(f"Skipped streams: {'ads_insights_hourly_advertiser'}")

assert base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done',\
self.assert_message.format(self.EXCLUDE_STREAMS)
exprected_streams = self.expected_metadata().keys() - self.EXCLUDE_STREAMS
LOGGER.warn(f"Skipped streams: {self.EXCLUDE_STREAMS}")

return exprected_streams

@staticmethod
def convert_state_to_utc(date_str):
Expand Down
25 changes: 14 additions & 11 deletions tests/test_facebook_start_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ def name():
return "tap_tester_facebook_start_date_test"

def streams_to_test(self):
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
if self.is_done is None:
self.is_done = base.JIRA_CLIENT.get_status_category("TDL-24312") == 'done'
self.assert_message = ("JIRA ticket has moved to done, re-add the "
"applicable EXCLUDE_STREAMS to the test.")
self.is_done_2 = base.JIRA_CLIENT.get_status_category("TDL-26640") == 'done'
# if either card is done, fail & update the test to include more streams
self.is_done = self.is_done or self.is_done_2
assert self.is_done != True, self.assert_message

return self.expected_streams() - self.EXCLUDE_STREAMS
exprected_streams = self.expected_metadata().keys()
self.assert_message = f"JIRA ticket has moved to done, \
re-add the applicable stream to the test: {0}"
assert base.JIRA_CLIENT.get_status_category("TDL-24312") != 'done',\
self.assert_message.format('ads_insights_hourly_advertiser')
exprected_streams = self.expected_metadata().keys() - {'ads_insights_hourly_advertiser'}
LOGGER.warn(f"Skipped streams: {'ads_insights_hourly_advertiser'}")

assert base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done',\
self.assert_message.format(self.EXCLUDE_STREAMS)
exprected_streams = self.expected_metadata().keys() - self.EXCLUDE_STREAMS
LOGGER.warn(f"Skipped streams: {self.EXCLUDE_STREAMS}")

return exprected_streams

def test_run(self):
"""Instantiate start date according to the desired data set and run the test"""
Expand Down
27 changes: 15 additions & 12 deletions tests/test_facebook_table_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import base
from base_new_frmwrk import FacebookBaseTest
from tap_tester.base_suite_tests.table_reset_test import TableResetTest
from tap_tester import LOGGER


class FacebookTableResetTest(TableResetTest, FacebookBaseTest):
Expand All @@ -28,18 +29,20 @@ def name():
}

def streams_to_test(self):
# return set(self.expected_metadata().keys())
# Fail the test when the JIRA card is done to allow stream to be re-added and tested
if self.is_done is None:
self.is_done = base.JIRA_CLIENT.get_status_category("TDL-24312") == 'done'
self.assert_message = ("JIRA ticket has moved to done, re-add the "
"applicable EXCLUDE_STREAMS to the test.")
self.is_done_2 = base.JIRA_CLIENT.get_status_category("TDL-26640") == 'done'
# if either card is done, fail & update the test to include more streams
self.is_done = self.is_done or self.is_done_2
assert self.is_done != True, self.assert_message

return self.expected_metadata().keys() - self.EXCLUDE_STREAMS
exprected_streams = self.expected_metadata().keys()
self.assert_message = f"JIRA ticket has moved to done, \
re-add the applicable stream to the test: {0}"
assert base.JIRA_CLIENT.get_status_category("TDL-24312") != 'done',\
self.assert_message.format('ads_insights_hourly_advertiser')
exprected_streams = self.expected_metadata().keys() - {'ads_insights_hourly_advertiser'}
LOGGER.warn(f"Skipped streams: {'ads_insights_hourly_advertiser'}")

assert base.JIRA_CLIENT.get_status_category("TDL-26640") != 'done',\
self.assert_message.format(self.EXCLUDE_STREAMS)
exprected_streams = self.expected_metadata().keys() - self.EXCLUDE_STREAMS
LOGGER.warn(f"Skipped streams: {self.EXCLUDE_STREAMS}")

return exprected_streams

@property
def reset_stream(self):
Expand Down

0 comments on commit 7ad5e8b

Please sign in to comment.