Beispiel #1
0
    def test_multiple_edge_traversal_with_type_filtering(self):
        """ Tests that using multiple edges for traversals works """
        v = TestModel.create(count=1, text='Test1')

        v1 = TestModel.create()
        TestEdge.create(v, v1)

        v2 = TestModel.create()
        OtherTestEdge.create(v, v2)

        v3 = TestModel.create()
        YetAnotherTestEdge.create(v, v3)

        v4 = OtherTestModel.create()
        TestEdge.create(v, v4)

        v5 = OtherTestModel.create()
        OtherTestEdge.create(v, v5)

        v6 = OtherTestModel.create()
        YetAnotherTestEdge.create(v, v6)

        assert len(v.outV()) == 6

        assert len(v.outV(TestEdge, OtherTestEdge)) == 4
        assert len(v.outV(TestEdge, OtherTestEdge, types=[TestModel])) == 2
Beispiel #2
0
    def test_multiple_edge_traversal_with_type_filtering(self):
        """ Tests that using multiple edges for traversals works """
        v = TestModel.create(count=1, text='Test1')

        v1 = TestModel.create()
        TestEdge.create(v, v1)

        v2 = TestModel.create()
        OtherTestEdge.create(v, v2)

        v3 = TestModel.create()
        YetAnotherTestEdge.create(v, v3)

        v4 = OtherTestModel.create()
        TestEdge.create(v, v4)

        v5 = OtherTestModel.create()
        OtherTestEdge.create(v, v5)

        v6 = OtherTestModel.create()
        YetAnotherTestEdge.create(v, v6)

        assert len(v.outV()) == 6

        assert len(v.outV(TestEdge, OtherTestEdge)) == 4
        assert len(v.outV(TestEdge, OtherTestEdge, types=[TestModel])) == 2
Beispiel #3
0
    def test_success_case(self):
        """ Tests that the update method works as expected """
        tm = TestModel.create(count=8, text='123456789')
        tm2 = tm.update(count=9)

        tm3 = TestModel.get(tm.vid)
        assert tm2.count == 9
        assert tm3.count == 9
Beispiel #4
0
    def test_success_case(self):
        """ Tests that the update method works as expected """
        tm = TestModel.create(count=8, text='123456789')
        tm2 = tm.update(count=9)

        tm3 = TestModel.get(tm.vid)
        assert tm2.count == 9
        assert tm3.count == 9
Beispiel #5
0
 def test_model_deleting_works_properly(self):
     """
     Tests that an instance's delete method deletes the instance
     """
     tm = TestModel.create(count=8, text='123456789')
     vid = tm.vid
     tm.delete()
     with self.assertRaises(TestModel.DoesNotExist):
         tm2 = TestModel.get(vid)
Beispiel #6
0
 def test_model_deleting_works_properly(self):
     """
     Tests that an instance's delete method deletes the instance
     """
     tm = TestModel.create(count=8, text='123456789')
     vid = tm.vid
     tm.delete()
     with self.assertRaises(TestModel.DoesNotExist):
         tm2 = TestModel.get(vid)
Beispiel #7
0
    def test_reload(self):
        """ Tests that and instance's reload method does an inplace update of the instance """
        tm0 = TestModel.create(count=8, text='123456789')
        tm1 = TestModel.get(tm0.vid)
        tm1.count = 7
        tm1.save()

        tm0.reload()
        assert tm0.count == 7
Beispiel #8
0
    def test_reload(self):
        """ Tests that and instance's reload method does an inplace update of the instance """
        tm0 = TestModel.create(count=8, text='123456789')
        tm1 = TestModel.get(tm0.vid)
        tm1.count = 7
        tm1.save()

        tm0.reload()
        assert tm0.count == 7
    def test_value_managers_are_keeping_model_instances_isolated(self):
        """
        Tests that instance value managers are isolated from other instances
        """
        inst1 = TestModel(count=5)
        inst2 = TestModel(count=7)

        self.assertNotEquals(inst1.count, inst2.count)
        self.assertEquals(inst1.count, 5)
        self.assertEquals(inst2.count, 7)
Beispiel #10
0
    def test_model_save_and_load(self):
        """
        Tests that models can be saved and retrieved
        """
        tm0 = TestModel.create(count=8, text='123456789')
        tm1 = TestModel.create(count=9, text='456789')
        tms = TestModel.all([tm0.vid, tm1.vid])

        assert len(tms) == 2
       
        for cname in tm0._columns.keys():
            self.assertEquals(getattr(tm0, cname), getattr(tms[0], cname))
            
        tms = TestModel.all([tm1.vid, tm0.vid])
        assert tms[0].vid == tm1.vid 
        assert tms[1].vid == tm0.vid 
Beispiel #11
0
    def test_model_save_and_load(self):
        """
        Tests that models can be saved and retrieved
        """
        tm0 = TestModel.create(count=8, text='123456789')
        tm1 = TestModel.create(count=9, text='456789')
        tms = TestModel.all([tm0.vid, tm1.vid])

        assert len(tms) == 2

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

        tms = TestModel.all([tm1.vid, tm0.vid])
        assert tms[0].vid == tm1.vid
        assert tms[1].vid == tm0.vid
Beispiel #12
0
    def test_model_updating_works_properly(self):
        """
        Tests that subsequent saves after initial model creation work
        """
        tm = TestModel.create(count=8, text='123456789')

        tm.count = 100
        tm.save()

        tm.count = 80
        tm.save()

        tm.count = 60
        tm.save()

        tm.count = 40
        tm.save()

        tm.count = 20
        tm.save()

        tm2 = TestModel.get(tm.vid)
        self.assertEquals(tm.count, tm2.count)
Beispiel #13
0
    def test_model_updating_works_properly(self):
        """
        Tests that subsequent saves after initial model creation work
        """
        tm = TestModel.create(count=8, text='123456789')

        tm.count = 100
        tm.save()

        tm.count = 80
        tm.save()

        tm.count = 60
        tm.save()

        tm.count = 40
        tm.save()

        tm.count = 20
        tm.save()

        tm2 = TestModel.get(tm.vid)
        self.assertEquals(tm.count, tm2.count)
    def test_column_attributes_handled_correctly(self):
        """
        Tests that column attributes are moved to a _columns dict
        and replaced with simple value attributes
        """

        #check class attibutes
        self.assertHasAttr(TestModel, '_columns')
        self.assertHasAttr(TestModel, 'vid')
        self.assertHasAttr(TestModel, 'text')

        #check instance attributes
        inst = TestModel()
        self.assertHasAttr(inst, 'vid')
        self.assertHasAttr(inst, 'text')
        self.assertIsNone(inst.vid)
        self.assertIsNone(inst.text)
Beispiel #15
0
 def setUp(self):
     super(TestEdgeIO, self).setUp()
     self.v1 = TestModel.create(count=8, text="a")
     self.v2 = TestModel.create(count=7, text="b")
Beispiel #16
0
 def setUp(self):
     super(TestEdgeIO, self).setUp()
     self.v1 = TestModel.create(count=8, text='a')
     self.v2 = TestModel.create(count=7, text='b')
Beispiel #17
0
 def test_unicode_io(self):
     """
     Tests that unicode is saved and retrieved properly
     """
     tm1 = TestModel.create(count=9, text=u'4567ë9989')
     tm2 = TestModel.get(tm1.vid)
Beispiel #18
0
 def test_unknown_names_raise_exception(self):
     """ Tests that passing in names for columns that don't exist raises an exception """
     tm = TestModel.create(count=8, text='123456789')
     with self.assertRaises(TypeError):
         tm.update(jon='beard')
Beispiel #19
0
 def setUp(self):
     super(TestVertexTraversal, self).setUp()
     self.v1 = TestModel.create(count=1, text='Test1')
     self.v2 = TestModel.create(count=2, text='Test2')
     self.v3 = OtherTestModel.create(count=3, text='Test3')
Beispiel #20
0
 def test_unicode_io(self):
     """
     Tests that unicode is saved and retrieved properly
     """
     tm1 = TestModel.create(count=9, text=u'4567ë9989')
     tm2 = TestModel.get(tm1.vid)
Beispiel #21
0
 def test_unknown_names_raise_exception(self):
     """ Tests that passing in names for columns that don't exist raises an exception """
     tm = TestModel.create(count=8, text='123456789')
     with self.assertRaises(TypeError):
         tm.update(jon='beard')
Beispiel #22
0
 def setUp(self):
     super(TestVertexTraversal, self).setUp()
     self.v1 = TestModel.create(count=1, text='Test1')
     self.v2 = TestModel.create(count=2, text='Test2')
     self.v3 = OtherTestModel.create(count=3, text='Test3')
     self.v4 = OtherTestModel.create(count=3, text='Test3')