Skip to content

Commit

Permalink
Merge pull request #123 from ServiceNow/scratch/fix-add-tests-121
Browse files Browse the repository at this point in the history
fix!: unbreak 1.1.9
  • Loading branch information
vetsin authored Oct 15, 2024
2 parents d0ab688 + 9d035ad commit 5abd882
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pysnc/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def serialize_all(self, display_value=False, fields=None, fmt=None, exclude_refe
:param fmt:
:return: list
"""
return [record.serialize(display_value=display_value, fields=fields, fmd=fmt, exclude_reference_link=exclude_reference_link) for record in self]
return [record.serialize(display_value=display_value, fields=fields, fmt=fmt, exclude_reference_link=exclude_reference_link) for record in self]

def to_pandas(self, columns=None, mode='smart'):
"""
Expand Down
21 changes: 21 additions & 0 deletions test/test_snc_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,26 @@ def test_str(self):
self.assertTrue('intfield' in data)
client.session.close()

def test_serialize_all(self):
client = ServiceNowClient(self.c.server, self.c.credentials)
gr = client.GlideRecord('problem')
gr.fields = 'sys_id,short_description,state'
gr.limit = 4
gr.query()
data = gr.serialize_all()
self.assertEqual(len(data), 4)
for prb in data:
self.assertEqual(list(prb.keys()), ['sys_id', 'short_description', 'state'])

# we do *not* expect the link if we are value-only
data = gr.serialize_all(exclude_reference_link=False)
self.assertEqual(type(data[0]['short_description']), str)

# TODO: test this
#data = gr.serialize_all(display_value='both', exclude_reference_link=False)
#self.assertEqual(type(data[0]['short_description']), dict)
#print(data[0]['short_description'])
#self.assertTrue('value' in data[0]['short_description']['link'])
client.session.close()


0 comments on commit 5abd882

Please sign in to comment.