Skip to content

Commit

Permalink
improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctri-The-Third committed Jun 11, 2022
1 parent 61f8c21 commit cb3c57d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_zendesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ZendeskOrganisation,
ZendeskUser,
ZendeskWorklog,
ZendeskTicket,
)

ZENDESK_HOST = os.environ.get("ZENDESK_HOST")
Expand Down Expand Up @@ -131,14 +132,18 @@ def test_user_init_and_invalid_handling(caplog):
def test_search_for_tickets(caplog):
"Check for tickets belonging to a specific group"
zend = zendesk(ZENDESK_HOST, ZENDESK_KEY)
search_str = "requester:[email protected]"
search_str = "1239674"

tickets = zend.search_for_tickets(search_string=search_str)

assert len(tickets) > 0

for entry in caplog.records:
assert entry.levelno < logging.ERROR

for _, ticket in tickets.items():
assert isinstance(ticket, ZendeskTicket)


def test_worklog_parse():
"check that if missing fields aren't supplied, the worklog is not reported as valid"
Expand Down Expand Up @@ -171,3 +176,20 @@ def test_get_worklogs_from_audit(caplog):
assert len(logs) > 0
for entry in caplog.records:
assert entry.levelno < logging.ERROR


def test_custom_fields():
"Fetches a test ticket and checks that there are appropriate custom fields populated"

target_id = 1239674

zend = zendesk(ZENDESK_HOST, ZENDESK_KEY)

tickets = zend.search_for_tickets(f"{target_id}")
ticket = tickets[1239674]
ticket: ZendeskTicket

assert isinstance(ticket.custom_fields, dict)
for field_id in ticket.custom_fields:
isinstance(ticket.custom_fields[field_id], (bool, str))
assert True

0 comments on commit cb3c57d

Please sign in to comment.