def test_document_access_values_by_attribute_getter(self): doc = Document(id='', key='', collection='', api=client.api) # set this to true so it won't make requests to nothing doc.is_loaded = True doc_attr_value = 'foo_bar' doc.set(key='test', value=doc_attr_value) self.assertEqual(doc.test, doc_attr_value)
def create_document_from_result_dict(result_dict, api): collection_name = result_dict['_id'].split('/')[0] doc = Document( id=result_dict['_id'], key=result_dict['_key'], collection=collection_name, api=api, ) doc.is_loaded = True del result_dict['_id'] del result_dict['_key'] del result_dict['_rev'] for result_key in result_dict: result_value = result_dict[result_key] doc.set(key=result_key, value=result_value) return doc