def test_uniqueness(self): paul = Person(name="paul") self.db.put(paul) dog1 = Dog(name="rufus", owner_id=paul.key, kennel_club_membership="123456") dog1.save(self.db) # time.sleep(1) # print dog1.as_json() # dog2 = Dog(name="fly", owner_id=paul.key, kennel_club_membership="123456") # print dog2.as_json() # # self.db.put(dog2) # self.assertRaises(FamUniqueError, self.db.put, dog2) # # print "*********** end ***************" # class RefNameTests(unittest.TestCase): # # # this test that refs whos name doesnt end with _id fail # def test_misnamed_ref_to_fails(self): # # def duff_import(): # from fam.tests.models import test02 # print(test02) # # self.assertRaises(FamError, duff_import)
def test_uniqueness(self): paul = Person(name="paul") self.db.put(paul) dog1 = Dog(name="rufus", owner_id=paul.key, kennel_club_membership="123456") dog1.save(self.db)
def test_make_an_object_saved(self): dog = Dog(name="woofer") dog.save(self.db) self.assertEqual(dog.namespace, NAMESPACE) self.assertEqual(dog.type, "dog") self.assertEqual(dog.name, "woofer") self.assertEqual(dog.__class__, Dog) self.assertNotEqual(dog.key, None)
def test_make_an_object_saved(self): dog = Dog(name="woofer") dog.save(self.db) self.assertEqual(dog.namespace, NAMESPACE) self.assertEqual(dog.type, "dog") self.assertEqual(dog.name, "woofer") self.assertEqual(dog.__class__, Dog) self.assertNotEqual(dog.key, None)
def test_delete_dog_refs(self): paul = Person(name="paul") paul.save(self.db) dog = Dog(name="rufus", owner_id=paul.key) dog.save(self.db) key = dog.key dog2 = Dog(name="fly", owner_id=paul.key) dog2.save(self.db) reviveddog1 = self.db.get(key) self.assertTrue(reviveddog1 is not None) paul.delete(self.db) reviveddog2 = self.db.get(key) self.assertTrue(reviveddog2 is not None)
def test_delete_dog_refs(self): paul = Person(name="paul") paul.save(self.db) dog = Dog(name="rufus", owner_id=paul.key) dog.save(self.db) key = dog.key dog2 = Dog(name="fly", owner_id=paul.key) dog2.save(self.db) reviveddog1 = self.db.get(key) self.assertTrue(reviveddog1 is not None) paul.delete(self.db) reviveddog2 = self.db.get(key) self.assertTrue(reviveddog2 is not None)
def test_delete_dog_to_refs(self): paul = Person(name="paul") paul.save(self.db) dog = Dog(name="rufus", owner_id=paul.key) dog.save(self.db) key = dog.key dog2 = Dog(name="fly", owner_id=paul.key) dog2.save(self.db) self.assertTrue(dog2.owner is not None) key = paul.key dog.delete(self.db) revivedpaul = self.db.get(key) self.assertTrue(revivedpaul is None) refresheddog2 = Dog.get(self.db, dog2.key) self.assertTrue(refresheddog2.owner is None)
def test_delete_dog_to_refs(self): paul = Person(name="paul") paul.save(self.db) dog = Dog(name="rufus", owner_id=paul.key) dog.save(self.db) key = dog.key dog2 = Dog(name="fly", owner_id=paul.key) dog2.save(self.db) self.assertTrue(dog2.owner is not None) key = paul.key dog.delete(self.db) revivedpaul = self.db.get(key) self.assertTrue(revivedpaul is None) refresheddog2 = Dog.get(self.db, dog2.key) self.assertTrue(refresheddog2.owner is None)
def test_uniqueness(self): paul = Person(name="paul") self.db.put(paul) dog1 = Dog(name="rufus", owner_id=paul.key, kennel_club_membership="123456") dog1.save(self.db) time.sleep(1) print(dog1.as_json()) dog2 = Dog(name="fly", owner_id=paul.key, kennel_club_membership="123456") print(dog2.as_json()) # self.db.put(dog2) self.assertRaises(FamUniqueError, self.db.put, dog2)
def test_get(self): dog = Dog(name="fly") dog.save(self.db) dog_key = dog.key got_dog = self.db.get(dog_key) self.assertEqual(dog.name, got_dog.name)
def test_update_fails_without_rev(self): dog = Dog(name="fly") dog.save(self.db) dog.rev = None dog.name = "jess" self.assertRaises(FamResourceConflict, self.db.put, dog)
def test_update_dogfood(self): dog = Dog(name="fly") dog.food = "biscuits" dog.save(self.db)
def test_n1ql(self): dog = Dog(name="fly") dog.save(self.db) dogs = self.db.n1ql( 'SELECT META(test), * FROM test WHERE type="dog" and name="fly"')
def test_all(self): dog = Dog(name="fly") dog.save(self.db) all = Dog.all(self.db) self.assertEqual(len(all), 1)
def test_update_fails_without_rev(self): dog = Dog(name="fly") dog.save(self.db) dog.rev = None dog.name = "jess" self.assertRaises(FamResourceConflict, self.db.put, dog)
def test_update_dogfood(self): dog = Dog(name="fly") dog.food = "biscuits" dog.save(self.db)
def test_save(self): dog = Dog(name="fly") dog.save(self.db)
def test_all(self): dog = Dog(name="fly") dog.save(self.db) all = Dog.all(self.db) self.assertEqual(len(all), 1)
def test_n1ql(self): dog = Dog(name="fly") dog.save(self.db) dogs = self.db.n1ql('SELECT META(test).cas, META(test).id, * FROM test WHERE type="dog" and name="fly"')
def test_get(self): dog = Dog(name="fly") dog.save(self.db) dog_key = dog.key got_dog = self.db.get(dog_key) self.assertEqual(dog.name, got_dog.name)
def test_save(self): dog = Dog(name="fly") dog.save(self.db)