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

Tdl 12262 add ticket fields stream #52

Open
wants to merge 13 commits into
base: TDL-20356-update-function-based-to-class-based
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
79 changes: 79 additions & 0 deletions tap_freshdesk/schemas/ticket_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"type": "object",
"properties": {
"id": {
"type": ["null", "integer"]
},
"default": {
"type": ["null", "boolean"]
},
"description": {
"type": ["null", "string"]
},
"label": {
"type": ["null", "string"]
},
"name": {
"type": ["null", "string"]
},
"position": {
"type": ["null", "integer"]
},
"required_for_closure": {
"type": ["null", "boolean"]
},
"type": {
"type": ["null", "string"]
},
"required_for_agents": {
"type": ["null", "boolean"]
},
"required_for_customers": {
"type": ["null", "boolean"]
},
"label_for_customers": {
"type": ["null", "string"]
},
"customers_can_edit": {
"type": ["null", "boolean"]
},
"displayed_to_customers": {
"type": ["null", "boolean"]
},
"portal_cc": {
"type": ["null", "boolean"]
},
"portal_cc_to": {
"type": ["null", "string"]
},
"choices": {},
Copy link
Member

Choose a reason for hiding this comment

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

Why the type is not mentioned for choices?

Copy link
Author

Choose a reason for hiding this comment

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

As per the Freshdesk API documentation, choices is the list of values. But, in the actual response, we observed different types of values including a list of strings, plain object(dict), an object of the list, etc. That's why due to uncertainty in the value of this field, we kept {} as datatype and generally we keep {} in such cases.

"is_fsm": {
"type": ["null", "boolean"]
},
"field_update_in_progress": {
"type": ["null", "boolean"]
},
"dependent_fields": {
"type": ["null", "array"],
"items": {
"type": ["null", "object"],
"properties": {}
}
},
"section_mappings": {
"type": ["null", "array"],
"items": {
"type": ["null", "object"],
"properties": {}
}
},
"created_at": {
"type": ["null", "string"],
"format": "date-time"
},
"updated_at": {
"type": ["null", "string"],
"format": "date-time"
}
}
}
9 changes: 8 additions & 1 deletion tap_freshdesk/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ class TimeEntries(ChildStream):
path = 'tickets/{}/time_entries'
parent = 'tickets'

class TicketFields(Stream):
tap_stream_id = 'ticket_fields'
key_properties = ['id']
replication_keys = ['updated_at']
replication_method = 'INCREMENTAL'
path = 'ticket_fields'

STREAMS = {
"agents": Agents,
Expand All @@ -311,5 +317,6 @@ class TimeEntries(ChildStream):
"roles": Roles,
"satisfaction_ratings": SatisfactionRatings,
"tickets": Tickets,
"time_entries": TimeEntries
"time_entries": TimeEntries,
'ticket_fields': TicketFields
}
6 changes: 6 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def expected_metadata(self):
self.REPLICATION_KEYS: {"updated_at"},
self.OBEYS_START_DATE: True
},
"ticket_fields": {
self.PRIMARY_KEYS: {"id"},
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {"updated_at"},
self.OBEYS_START_DATE: True
}
}

#############################
Expand Down
2 changes: 1 addition & 1 deletion tests/test_freshdesk_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_run(self):
with self.subTest(stream=stream):
# Not able to generate more data as roles stream requires pro account.
# So, updating page_sie according to data available.
if stream == "roles":
if stream == "roles" or stream == "ticket_fields":

Choose a reason for hiding this comment

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

Suggested change
if stream == "roles" or stream == "ticket_fields":
if stream in ["roles", "ticket_fields"]:

Copy link
Author

Choose a reason for hiding this comment

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

Updated.

page_size = 2
else:
page_size = 100
Expand Down
20 changes: 16 additions & 4 deletions tests/test_freshdesk_start_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ def name():
return "tap_tester_freshdesk_start_date_test"

def test_run(self):
# Streams to verify start date tests
Copy link
Member

Choose a reason for hiding this comment

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

Please add the doc string.

Copy link
Author

Choose a reason for hiding this comment

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

Added docstring to describe the test_run function.

expected_streams = self.expected_streams()

# To collect "time_entries", "satisfaction_ratings" pro account is needed. Skipping them for now.
expected_streams = expected_streams - {'satisfaction_ratings', 'time_entries'}
Copy link
Member

Choose a reason for hiding this comment

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

Can we merge these two separate lines into one?

expected_streams = self.expected_streams() - {'satisfaction_ratings', 'time_entries'}

Copy link
Author

Choose a reason for hiding this comment

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

Merged mentioned two lines to reduce redundancy.


# running start_date_test for `ticket_fields` stream
expected_stream_1 = {"ticket_fields"}
self.run_start_date(expected_stream_1, "2019-07-19T00:00:00Z")

# running start_date_test for rest of the streams
expected_streams = expected_streams - expected_stream_1
self.run_start_date(expected_streams, "2022-07-19T00:00:00Z")

def run_start_date(self, expected_streams, new_start_date):
"""
• Verify that a sync with a later start date has at least one record synced
and less records than the 1st sync with a previous start date
Expand All @@ -28,16 +43,13 @@ def test_run(self):
"""

self.start_date_1 = self.get_properties().get('start_date')
self.start_date_2 = "2022-07-19T00:00:00Z"
self.start_date_2 = new_start_date

self.start_date = self.start_date_1

start_date_1_epoch = self.dt_to_ts(self.start_date_1, self.START_DATE_FORMAT)
start_date_2_epoch = self.dt_to_ts(self.start_date_2, self.START_DATE_FORMAT)

# To collect "time_entries", "satisfaction_ratings" pro account is needed. Skipping them for now.
expected_streams = self.expected_streams() - {'satisfaction_ratings', 'time_entries'}

##########################################################################
### First Sync
##########################################################################
Expand Down