How to use the mixer.generators.get_choice function in mixer

To help you get started, we’ve selected a few mixer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klen / mixer / mixer / fakers.py View on Github external
def get_country_code():
    """ Get a country code.

    :return str:

    ::

        print get_country_code()  # -> ru

    """
    return g.get_choice(COUNTRY_CODES)
github klen / mixer / mixer / fakers.py View on Github external
def get_city(**kwargs):
    """ Get a city.

    :return str:

    ::

        print get_city()  # -> North Carter

    """
    prf, sfx, city = g.get_choice(CITY_PREFIXIES), g.get_choice(CITY_SUFFIXIES), g.get_choice(CITIES) #noqa

    return g.get_choice((
        city,
        "{0} {1}".format(prf, city),
        "{0} {1}".format(prf, get_firstname()),
        "{0} {1}".format(get_lastname(), sfx),
    ))
github klen / mixer / mixer / fakers.py View on Github external
def get_street(**kwargs):
    """ Generate street name. """
    params = dict(
        first_name=get_firstname(),
        last_name=get_lastname(),
        suffix=g.get_choice(STREET_SUFFIXES),
    )

    return g.get_choice((
        '{first_name} {suffix}'.format(**params),
        '{last_name} {suffix}'.format(**params)
    ))
github klen / mixer / mixer / fakers.py View on Github external
def get_street(**kwargs):
    """ Generate street name. """
    params = dict(
        first_name=get_firstname(),
        last_name=get_lastname(),
        suffix=g.get_choice(STREET_SUFFIXES),
    )

    return g.get_choice((
        '{first_name} {suffix}'.format(**params),
        '{last_name} {suffix}'.format(**params)
    ))
github klen / mixer / mixer / fakers.py View on Github external
def get_short_lorem(length=64, **kwargs):
    """ Get a small text (based on lorem ipsum.

    :return str:

    ::

        print get_short_lorem()  # -> atque rerum et aut reiciendis

    """
    lorem = g.get_choice(LOREM_CHOICES)
    while True:
        choice = g.get_choice(LOREM_CHOICES)
        if len(lorem + choice) > length - 1:
            return lorem
        lorem += ' ' + choice