Cal-CS-61A-Staff/ok — pull request #37 by papajohn (2014-07-28 08:44:07+00:00)
Title: Add requests requirement and make to_dict more robust

Tests were failing for me because of the new to_dict assuming that every entity has a key. In particular, see trace below. Perhaps the deeper problem is that the test infrastructure doesn't create valid entities.

======================================================================
ERROR: test_entity_create_basic (test_api.AssignmentAPITest)
Tests creating an empty entity.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/denero/Documents/workspace/ok/server/tests/test_api.py", line 185, in test_entity_create_basic
self.post_entity(self.inst)
File "/Users/denero/Documents/workspace/ok/server/tests/test_api.py", line 100, in post_entity
self.post_json('/{}/new'.format(self.name), data=inst, *args, **kwds)
File "/Users/denero/Documents/workspace/ok/server/tests/test_api.py", line 89, in post_json
data = data.to_dict()
File "/Users/denero/Documents/workspace/ok/server/app/models.py", line 47, in to_dict
result['key'] = self.key.id() #get the key as a string
AttributeError: 'NoneType' object has no attribute 'id'