Beispiel #1
0
 def test_setMatch_valid(self):
     fields = [
         number_field("field", 3, 100, 7),
         number_field("field", 3, 100, 8)
     ]
     match = OpenFlowMatch(fields)
     rule = OpenFlowRule()
     rule.setMatch(match)
Beispiel #2
0
 def test_setInstruction_invalid1(self):
     instruction = "blah"
     rule = OpenFlowRule()
     try:
         rule.setInstruction(instruction)
     except TypeError:
         pass
     else:
         self.fail("did not see error")
Beispiel #3
0
 def test_setMatch_invalid(self):
     match = "blah"
     rule = OpenFlowRule()
     try:
         rule.setMatch(match)
     except TypeError:
         pass
     else:
         self.fail("did not see error")
Beispiel #4
0
 def test_invalid_init5(self):
     fields = [Field("field"), Field("field")]
     match = OpenFlowMatch(fields)
     instruction = instruction_GOTO_TABLE(3)
     table = 1
     priority = 100
     cookie = 123456789012345678  #invalid
     try:
         OpenFlowRule(match, instruction, table, priority, cookie)
     except ValueError:
         pass
     else:
         self.fail("did not see error")
Beispiel #5
0
 def test_invalid_init4(self):
     fields = [number_field("field", 3, 100), number_field("field", 3, 100)]
     match = OpenFlowMatch(fields)
     instruction = instruction_GOTO_TABLE(3)
     table = 1
     priority = -100  #invalid
     cookie = 1234
     try:
         OpenFlowRule(match, instruction, table, priority, cookie)
     except ValueError:
         pass
     else:
         self.fail("did not see error")
Beispiel #6
0
    def test_invalid_init6(self):
        fields = [Field("field"), Field("field")]
        match = OpenFlowMatch(fields)
        instruction = instruction_GOTO_TABLE(3)
        table = 1
        priority = 100
        cookie = 1234
        switch_id = "a"

        try:
            OpenFlowRule(match, instruction, table, priority, cookie,
                         switch_id)
        except TypeError:
            pass
        else:
            self.fail("did not see error")
Beispiel #7
0
    def test_basic_init(self):
        fields = [Field("field"), Field("field")]
        match = OpenFlowMatch(fields)
        instruction = instruction_GOTO_TABLE(3)
        table = 1
        priority = 100
        cookie = 1234

        OpenFlowRule(match, instruction, table, priority, cookie)
        OpenFlowRule(match, instruction, table)
        OpenFlowRule(match, instruction, priority=priority)
        OpenFlowRule(match)

        print OpenFlowRule(match, instruction, table, priority,
                           cookie).__repr__()
        print OpenFlowRule(match, instruction, table, priority, cookie)
Beispiel #8
0
    def test_setPriority_invalid1(self):
        priority = "blah"
        rule = OpenFlowRule()
        try:
            rule.setPriority(priority)
        except TypeError:
            pass
        else:
            self.fail("did not see error")

        priority = -1
        try:
            rule.setPriority(priority)
        except ValueError:
            pass
        else:
            self.fail("did not see error")
Beispiel #9
0
    def test_setTable_invalid1(self):
        table = "blah"
        rule = OpenFlowRule()
        try:
            rule.setTable(table)
        except TypeError:
            pass
        else:
            self.fail("did not see error")

        table = -1
        try:
            rule.setTable(table)
        except ValueError:
            pass
        else:
            self.fail("did not see error")
Beispiel #10
0
    def test_setCookie_invalid1(self):
        cookie = "blah"
        rule = OpenFlowRule()
        try:
            rule.setCookie(cookie)
        except TypeError:
            pass
        else:
            self.fail("did not see error")

        cookie = -1
        try:
            rule.setCookie(cookie)
        except ValueError:
            pass
        else:
            self.fail("did not see error")
Beispiel #11
0
 def test_empty_init(self):
     # This is valid for OpenFlowRules
     rule = OpenFlowRule()
Beispiel #12
0
 def test_setPriority_valid(self):
     priority = 100
     rule = OpenFlowRule()
     rule.setPriority(priority)
Beispiel #13
0
 def test_setTable_valid(self):
     table = 1
     rule = OpenFlowRule()
     rule.setTable(table)
Beispiel #14
0
 def test_setCookie_valid(self):
     cookie = 1234
     rule = OpenFlowRule()
     rule.setCookie(cookie)
Beispiel #15
0
 def test_setInstruction_valid(self):
     instruction = instruction_GOTO_TABLE(3)
     rule = OpenFlowRule()
     rule.setInstruction(instruction)
     pass