Closed dahifi closed 4 years ago
I believe some small adjustments to the QueryCursor object will fix this. I've made this commit 2530d48 to a branch and I have a test that is passing which indicates this should resolve the usage issues. my test looks like this. does that work for you?
class TestIntegratedQueryCursorFeatures(ConnectedTest):
def test_011_next_method(self):
complete = self.api.picklist['Ticket']['Status']['Complete']
query = atws.Query('Ticket')
query.WHERE('Status', query.Equals, complete)
tickets = self.api.query(query)
ticket = tickets.next()
self.assertEqual(ticket.Status, complete, 'It may not be related to '
'the query cursor next failing if this does not pass '
'as it could be the lookup values')
ticket2 = next(tickets)
self.assertEqual(ticket2.Status, complete, 'It is unlikely related to '
'the query cursor next failing if this does not pass '
'as the failure will probably be an exception on the '
'next call')
i=0
for ticket in tickets:
i+=1
self.assertEqual(ticket.Status, complete)
if i>2:
break
TBH Matt, it's been a few weeks since I ran my library, but I appreciate you keeping up with it. It's obvious that the organization that I work for is not forward-thinking enough so I'm anticipating a career-change in May after I finish my degree. Keep up the good work!
From the docs under Query Result Cursor:
(I presume this is a typo, and is supposed to be
tickets.next()
)Using the following:
Python3 generators do not have 'next', and instead rely on the
__next__
attribute. We should be able to callnext(ticket)
, but this fails withTypeError: 'QueryCursor' object is not an iterator
.Calling
tickets.__next__()
works, as doesnext(iter(tickets)
, so I can return a generator using:I can submit a PR to update the docs unless you have other thoughts.