예제 #1
0
    def test_valid_port(self):
        """Test :py:func:`privex.pyrewall.core.valid_port` with a valid string and integer"""
        p = pyrewall.valid_port('1234')
        self.assertIs(type(p), int)
        self.assertEqual(p, 1234)

        k = pyrewall.valid_port(2345)
        self.assertIs(type(k), int)
        self.assertEqual(k, 2345)
예제 #2
0
 def test_invalid_port_negative(self):
     """Test valid_port raises InvalidPort with negative port -1"""
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port('-1')
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port(-1)
예제 #3
0
 def test_invalid_port_zero(self):
     """Test valid_port raises InvalidPort with port 0 """
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port('0')
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port(0)
예제 #4
0
 def test_invalid_port_overflow(self):
     """Test valid_port raises InvalidPort with a too high port number (65537)"""
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port('65537')
     with self.assertRaises(pyrewall.InvalidPort):
         pyrewall.valid_port(65537)