Exemple #1
0
def _gen(data_type, length, optional, encoding):
    if data_type == 'one_of':
        val = str(one_of(*optional))
        if len(val) == length:
            data = val
        else:
            raise GenieException(
                "Provided value {0} is not of length {1}".format(val, length))
    elif data_type == 'date':
        data = _generate_date(length, *optional)  # not passing delta days yet
    elif data_type == 'float':
        data = _generate_float(length, *optional)
    elif data_type == 'email':
        data = generate_email_id(length, *optional)
    elif data_type == 'int':
        data = _generate_int(length, *optional)
    else:
        data = _generate(length, encoding)

    return data
Exemple #2
0
def _gen(data_type, optional):
    if data_type == 'email':
        data = generate_email_id(*optional)
    elif data_type == 'int':
        data = str(random_integer(*optional))
    elif data_type == 'float':
        data = str(random_float(*optional))
    elif data_type == 'date':
        data = random_date_from_today(*optional)
    elif data_type == 'special_string':
        data = random_string_with_special_chars(*optional)
    elif data_type == 'geo_coord':
        data = random_geo_coords(*optional)
    elif data_type == 'cc_mastercard':
        data = random_mastercard_number()
    elif data_type == 'cc_visacard':
        data = random_visacard_number(*optional)
    elif data_type == 'one_of':
        data = one_of(*optional)
    else:
        data = random_string(*optional)

    return data
Exemple #3
0
 def get_city(self, state, postcode):
     localities = self.data[state][postcode]["localities"]
     return one_of(localities)
Exemple #4
0
 def get_random_city_postcode(self, state) -> Tuple[str, str]:
     state_data = self.data[state]
     post_codes = list(state_data.keys())
     pc = one_of(post_codes)
     locality = state_data[pc]["localities"]
     return (locality, pc)
Exemple #5
0
 def get_random_state(self) -> str:
     return one_of(list(self.data.keys()))
Exemple #6
0
def random_choice_of(choices) -> str:
    return str(one_of(choices))