class Couplet(resources.ScannableResource): class Meta: identifier = AutoId() address = attributes.Hostname() password = attributes.Password(crypt) internal_id = attributes.String(user_read_only=True, optional=True)
def test_hostname(self): hostname = attributes.Hostname() for value in ('intel.com', '127.0.0.1', 'my-laptop'): hostname.validate(value) for value in ('intel.-com', 'my_laptop', 'x.' * 128, 'x' * 64): with self.assertRaises(ValueError): hostname.validate(value) self.assertEqual(hostname.cast('host.intel.com'), 'host.intel.com')
def test_hostname(self): hostname = attributes.Hostname() for value in ("whamcloud.com", "127.0.0.1", "my-laptop"): hostname.validate(value) for value in ("whamcloud.-com", "my_laptop", "x." * 128, "x" * 64): with self.assertRaises(ValueError): hostname.validate(value) self.assertEqual(hostname.cast("host.whamcloud.com"), "host.whamcloud.com")
class Resource1(ScannableResource): class Meta: identifier = GlobalId("address1", "address2") address_1 = attributes.Hostname() address_2 = attributes.Hostname()
class Couplet(resources.ScannableResource): class Meta: identifier = identifiers.GlobalId('address_1', 'address_2') address_1 = attributes.Hostname() address_2 = attributes.Hostname()