0

I am using fixture to load testing data using ndb for my Google App Engine project using this patch. Inside my unit tests I often need to reference the underlying entity which causes me to do things like:

# MyEntityClass is an ndb.Model subclass
# MyEntityClassData is a fixture.DataSet
entity = MyEntityClass.get_by_id(MyEntityClassData.entity_one.id_field)

This just feels dirty. Is there a way to extract the entity class created for MyEntityClassData.entity_one directly from the fixture class?

Josh J
  • 6,813
  • 3
  • 25
  • 47
  • The fixture class contains references to entities in the form of ids. You're getting the entity using a get_by_id on that id. I can't think of a more straightforward way of doing it. What's dirty about that? – Adam Feb 21 '15 at 00:57
  • I guess you're right. I found references under a long object graph starting with `datasetinstance.data.meta.datasets` but I thought it would be more straightforward. The `with_data` decorator will pass them into your test method but it switches the order between `self` and your entities. – Josh J Feb 21 '15 at 12:52

0 Answers0