Ejemplo n.º 1
0
 def test_unicode_io(self):
     """
     Tests that unicode is saved and retrieved properly
     """
     tm1 = TestVertexModel.create(test_val=9, name=u'test2')
     tm2 = TestVertexModel.get(tm1._id)
     tm1.delete()
Ejemplo n.º 2
0
 def test_model_deleting_works_properly(self):
     """
     Tests that an instance's delete method deletes the instance
     """
     tm = TestVertexModel.create(test_val=8, name='123456789')
     vid = tm.id
     tm.delete()
     with self.assertRaises(TestVertexModel.DoesNotExist):
         tm2 = TestVertexModel.get(vid)
Ejemplo n.º 3
0
    def test_success_case(self):
        """ Tests that the update method works as expected """
        tm = TestVertexModel.create(test_val=8, name='123456789')
        tm2 = tm.update(test_val=9)

        tm3 = TestVertexModel.get(tm.id)
        self.assertEqual(tm2.test_val, 9)
        self.assertEqual(tm3.test_val, 9)
        tm.delete()
Ejemplo n.º 4
0
    def test_get_by_id(self):
        v1 = TestVertexModel.create()
        results = TestVertexModel.get(v1.id)
        self.assertIsInstance(results, TestVertexModel)
        self.assertEqual(results, v1)

        with self.assertRaises(TestEdgeModel.DoesNotExist):
            results = TestVertexModel.get(None)

        with self.assertRaises(TestEdgeModel.DoesNotExist):
            results = TestVertexModel.get('nonexistant')

        v2 = TestVertexModel2.create(test_val=0)
        with self.assertRaises(TestVertexModel.WrongElementType):
            results = TestVertexModel.get(v2.id)

        v2.delete()
        v1.delete()
Ejemplo n.º 5
0
    def test_reload(self):
        """ Tests that and instance's reload method does an inplace update of the instance """
        tm0 = TestVertexModel.create(test_val=8, name='123456789')
        tm1 = TestVertexModel.get(tm0.id)
        tm1.test_val = 7
        tm1.save()

        tm0.reload()
        self.assertEqual(tm0.test_val, 7)
        tm0.delete()
Ejemplo n.º 6
0
    def test_model_updating_works_properly(self):
        """
        Tests that subsequent saves after initial model creation work
        """
        tm = TestVertexModel.create(test_val=8, name='123456789')

        tm.test_val = 100
        tm.save()

        tm.test_val = 80
        tm.save()

        tm.test_val = 60
        tm.save()

        tm.test_val = 40
        tm.save()

        tm.test_val = 20
        tm.save()

        tm2 = TestVertexModel.get(tm.id)
        self.assertEquals(tm.test_val, tm2.test_val)
        tm.delete()