MediaMath / t1-python

Python SDK for MediaMath Platform APIs
https://developer.mediamath.com/
Apache License 2.0
18 stars 30 forks source link

Set iterators in parsers #90

Closed pswaminathan closed 8 years ago

pswaminathan commented 8 years ago

Nathan originally brought this up in #87 . In a lot of the service methods, we are expecting all entities to be an iterator, and using entity_count to see if something is a single entity or a collection. However, this doesn't account for instances where, for instance, you request a collection but it only has a single entity. We make it an iterator as we should, but the caller thinks it's an entity, so it chokes.

Here, we set iterators in the parsers themselves, such that callers only need check if something is an iterator. We can then check that in the service methods to determine how to parse the object.

@FodT @Cawb07 this is a fairly comprehensive change, so I could use a couple of CRs to make sure I haven't overlooked anything. It passes unit tests and acceptance tests, but could use some real-world and edge-case testing.

FodT commented 8 years ago

Looks good; much cleaner.

Cawb07 commented 8 years ago

@pswaminathan I'll try to run this code against my test cases today.

Cawb07 commented 8 years ago

@pswaminathan These changes also pass my tests :). Thank you!

pswaminathan commented 8 years ago

🙌