Revision 7df2c4f0 test/ganeti.netutils_unittest.py

b/test/ganeti.netutils_unittest.py
161 161
    self.assertEqual(fn("2001:db8::1"), socket.AF_INET6)
162 162
    self.assertRaises(errors.IPAddressError, fn, "0")
163 163

  
164
  def testValidateNetmask(self):
165
    for netmask in [0, 33]:
166
      self.assertFalse(netutils.IP4Address.ValidateNetmask(netmask))
167

  
168
    for netmask in [1, 32]:
169
      self.assertTrue(netutils.IP4Address.ValidateNetmask(netmask))
170

  
171
    for netmask in [0, 129]:
172
      self.assertFalse(netutils.IP6Address.ValidateNetmask(netmask))
173

  
174
    for netmask in [1, 128]:
175
      self.assertTrue(netutils.IP6Address.ValidateNetmask(netmask))
176

  
177
  def testGetClassFromX(self):
178
    self.assert_(
179
        netutils.IPAddress.GetClassFromIpVersion(constants.IP4_VERSION) ==
180
        netutils.IP4Address)
181
    self.assert_(
182
        netutils.IPAddress.GetClassFromIpVersion(constants.IP6_VERSION) ==
183
        netutils.IP6Address)
184
    self.assert_(
185
        netutils.IPAddress.GetClassFromIpFamily(socket.AF_INET) ==
186
        netutils.IP4Address)
187
    self.assert_(
188
        netutils.IPAddress.GetClassFromIpFamily(socket.AF_INET6) ==
189
        netutils.IP6Address)
190

  
164 191
  def testOwnLoopback(self):
165 192
    # FIXME: In a pure IPv6 environment this is no longer true
166 193
    self.assert_(netutils.IPAddress.Own("127.0.0.1"),

Also available in: Unified diff