Exemple #1
0
 def __init__(self, labels=None, down_revision=None, is_branch_point=False):
     if not labels:
         labels = set()
     self.branch_labels = labels
     self.down_revision = down_revision
     self.is_branch_point = is_branch_point
     self.revision = helpers.get_random_string(10)
     self.module = mock.MagicMock()
Exemple #2
0
 def __init__(self, labels=None, down_revision=None, is_branch_point=False):
     if not labels:
         labels = set()
     self.branch_labels = labels
     self.down_revision = down_revision
     self.is_branch_point = is_branch_point
     self.revision = helpers.get_random_string(10)
     self.module = mock.MagicMock()
Exemple #3
0
 def _create_test_network(self, name=None, network_id=None):
     name = "test-network-%s" % helpers.get_random_string(4)
     network_id = (uuidutils.generate_uuid() if network_id is None
                   else network_id)
     _network = net_obj.Network(self.context, name=name, id=network_id,
                                project_id=uuidutils.generate_uuid())
     _network.create()
     return _network
 def _create_test_network(self, name=None, network_id=None):
     name = "test-network-%s" % helpers.get_random_string(4)
     network_id = (uuidutils.generate_uuid() if network_id is None
                   else network_id)
     _network = net_obj.Network(self.context, name=name, id=network_id,
                                project_id=uuidutils.generate_uuid())
     _network.create()
     return _network
Exemple #5
0
def get_related_rand_names(prefixes, max_length=None):
    """Returns a list of the prefixes with the same random characters appended

    :param prefixes: A list of prefix strings
    :param max_length: The maximum length of each returned string
    :returns: A list with each prefix appended with the same random characters
    """

    if max_length:
        length = max_length - max(len(p) for p in prefixes)
        if length <= 0:
            raise ValueError(_("'max_length' must be longer than all prefixes"))
    else:
        length = 8
    rndchrs = helpers.get_random_string(length)
    return [p + rndchrs for p in prefixes]
Exemple #6
0
def get_related_rand_names(prefixes, max_length=None):
    """Returns a list of the prefixes with the same random characters appended

    :param prefixes: A list of prefix strings
    :param max_length: The maximum length of each returned string
    :returns: A list with each prefix appended with the same random characters
    """

    if max_length:
        length = max_length - max(len(p) for p in prefixes)
        if length <= 0:
            raise ValueError(
                _("'max_length' must be longer than all prefixes"))
    else:
        length = 8
    rndchrs = helpers.get_random_string(length)
    return [p + rndchrs for p in prefixes]
Exemple #7
0
def generate_tap_device_name():
    return n_consts.TAP_DEVICE_PREFIX + helpers.get_random_string(
        n_consts.DEVICE_NAME_MAX_LEN - len(n_consts.TAP_DEVICE_PREFIX))
Exemple #8
0
def get_random_string_list(i=3, n=5):
    return [helpers.get_random_string(n) for _ in range(0, i)]
Exemple #9
0
 def test_get_random_string(self):
     length = 127
     random_string = helpers.get_random_string(length)
     self.assertEqual(length, len(random_string))
     regex = re.compile('^[0-9a-fA-F]+$')
     self.assertIsNotNone(regex.match(random_string))
 def setUp(self):
     super(TestResourceAllocator, self).setUp()
     self.ra = resource_allocator.ResourceAllocator(
         helpers.get_random_string(6), lambda: 42)
     self.addCleanup(safe_remove_file, self.ra._state_file_path)
Exemple #11
0
def get_random_string_list(i=3, n=5):
    return [helpers.get_random_string(n) for _ in range(0, i)]
 def setUp(self):
     super(TestResourceAllocator, self).setUp()
     self.ra = resource_allocator.ResourceAllocator(
         helpers.get_random_string(6), lambda: 42)
     self.addCleanup(safe_remove_file, self.ra._state_file_path)
Exemple #13
0
def get_random_string(length):
    return helpers.get_random_string(length)
Exemple #14
0
 def test_get_random_string(self):
     length = 127
     random_string = helpers.get_random_string(length)
     self.assertEqual(length, len(random_string))
     regex = re.compile('^[0-9a-fA-F]+$')
     self.assertIsNotNone(regex.match(random_string))