示例#1
0
 def test5(self):
     self.createModel()
     selector = NodeSelector(self.root)
     selector.select(Selector("emulateddevice"))
     n = selector.select(Selector("ipv4if"))
     assert n == 2
示例#2
0
 def test8(self):
     self.createModel()
     selector = NodeSelector(self.root)
     selector.select(Selector("emulateddevice"))
     n = selector.select(Selector("ipv4if [ @name = ipv4if 1 ]"))
     assert n == 1
示例#3
0
 def test2(self):
     self.createModel()
     selector = NodeSelector(self.root)
     n = selector.select(Selector("xproject"))
     assert n == 0
示例#4
0
 def test4(self):
     self.createModel()
     selector = NodeSelector(self.root)
     n = selector.select(Selector("emulateddevice [@name= device x]"))
     assert n == 0
示例#5
0
    def test_intersect(self):
        self.createModel()
        set1 = NodeSelector(self.root)
        set2 = NodeSelector(self.root)
        set3 = NodeSelector(self.root)

        set1.select(Selector("port"))
        set2.select(Selector("port[name=port1]"))
        set3.select(Selector("port[name=nope]"))

        assert set1.intersect(set2).count() == 1
        assert set1.intersect(set3).count() == 0
        assert set1.intersect(None).count() == 0
示例#6
0
    def test_different(self):
        self.createModel()
        set1 = NodeSelector(self.root)
        set2 = NodeSelector(self.root)
        set3 = NodeSelector(self.root)

        set1.select(Selector("port[name=port1]"))
        set2.select(Selector("port[name=port1]"))
        set3.select(Selector("port[name=port11]"))

        assert set1.isDifferent(set2) == False
        assert set1.isDifferent(set3) == True
        assert set1.isDifferent(None) == True

        assert NodeSelector().isDifferent(set1)
        assert NodeSelector().isDifferent(NodeSelector()) == False
        assert NodeSelector().isDifferent(None)
        assert set1.isDifferent(NodeSelector())
示例#7
0
    def test_extend(self):
        self.createModel()
        set1 = NodeSelector(self.root)
        set2 = NodeSelector(self.root)
        set3 = NodeSelector(self.root)

        set1.select(Selector("port[name=port1]"))
        set2.select(Selector("port[name=port11]"))
        set3.select(Selector("port[name=nope]"))

        set1.extend(set2)
        assert set1.count() == 2
        assert set2.count() == 1

        set1.extend(set3)
        assert set1.count() == 2
        assert set3.count() == 0

        set1.extend(None)
        assert set1.count() == 2
示例#8
0
 def test11b(self):
     self.createModel()
     selector = NodeSelector(self.root)
     n = selector.select(Selector("port [ name = port3 4]"))
     assert n == 0
示例#9
0
 def test10a(self):
     self.createModel()
     selector = NodeSelector(self.root)
     n = selector.select(Selector("port [ name = port1 //10/1]"))
     assert n == 1