Esempio n. 1
0
    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)
Esempio n. 2
0
        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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
        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)
Esempio n. 10
0
 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)
Esempio n. 11
0
 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)
Esempio n. 12
0
 def test_update_dogfood(self):
     dog = Dog(name="fly")
     dog.food = "biscuits"
     dog.save(self.db)
Esempio n. 13
0
 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"')
Esempio n. 14
0
 def test_all(self):
     dog = Dog(name="fly")
     dog.save(self.db)
     all = Dog.all(self.db)
     self.assertEqual(len(all), 1)
Esempio n. 15
0
 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)
Esempio n. 16
0
 def test_update_dogfood(self):
     dog = Dog(name="fly")
     dog.food = "biscuits"
     dog.save(self.db)
Esempio n. 17
0
 def test_save(self):
     dog = Dog(name="fly")
     dog.save(self.db)
Esempio n. 18
0
 def test_all(self):
     dog = Dog(name="fly")
     dog.save(self.db)
     all = Dog.all(self.db)
     self.assertEqual(len(all), 1)
Esempio n. 19
0
 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"')
Esempio n. 20
0
 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)
Esempio n. 21
0
 def test_save(self):
     dog = Dog(name="fly")
     dog.save(self.db)