

def test_readwrite(self):
    s = IndexedData(name='Pre', descrip='Testing', age=10)
    self.assertEquals('', s.id)
    self.assertEquals('Pre', s.name)
    self.assertEquals('Testing', s.descrip)
    self.assertEquals(10, s.age)
    s.save()
    self.assertTrue((len(s.id) > 0))
    self.assertReadable(s)
    s2 = IndexedData(id=s.id, name='Post', descrip='AtItAgain', age=256)
    s2.save()
    self.assertReadable(s2)
    all_recs = IndexedData.find_all()
    self.assertEqual(1, len(all_recs))
    self.assertObjEq(s2, all_recs[0])
    idx_recs = IndexedData.find_by_index('half_age', 128)
    self.assertEqual(1, len(idx_recs))
    self.assertObjEq(s2, idx_recs[0])
    idx_recs = IndexedData.find_by_index('my_name', 'Post')
    self.assertEqual(1, len(idx_recs))
    self.assertObjEq(s2, idx_recs[0])
    self.assertEqual(0, len(IndexedData.find_by_index('half_age', 0)))
    self.assertEqual(0, len(IndexedData.find_by_index('my_name', '')))

dataset/ETHPy150Open memphis-iis/GLUDB/tests/index_tests.py IndexReadWriteTesting.test_readwrite/original