Ejemplo n.º 1
0
 def test_all_method_invalid_length(self):
     v1 = TestVertexModel.create()
     v2 = TestVertexModel.create()
     from mogwai.exceptions import MogwaiQueryError
     with self.assertRaises(MogwaiQueryError):
         TestVertexModel.all([v1.id, v2.id, 'invalid'])
     v1.delete()
     v2.delete()
Ejemplo n.º 2
0
    def test_model_save_and_load(self):
        """
        Tests that models can be saved and retrieved
        """
        tm0 = TestVertexModel.create(test_val=8, name='123456789')
        tm1 = TestVertexModel.create(test_val=9, name='456789')
        tms = TestVertexModel.all([tm0.id, tm1.id])

        self.assertEqual(len(tms), 2)

        for pname in tm0._properties.keys():
            self.assertEquals(getattr(tm0, pname), getattr(tms[0], pname))

        tms = TestVertexModel.all([tm1.id, tm0.id])
        self.assertEqual(tms[0].id, tm1.id)
        self.assertEqual(tms[1].id, tm0.id)

        tm0.delete()
        tm1.delete()
Ejemplo n.º 3
0
 def test_all_method(self):
     with self.assertRaises(MogwaiQueryError):
         TestVertexModel.all(1)