Exemple #1
0
    def test_override(self, locale, new_locale):
        provider = Person(locale)
        assert provider.locale == locale

        with provider.override_locale(new_locale):
            assert 'Жен.' in provider._data['gender']
            assert provider.locale == new_locale

        assert provider.locale == locale
        assert 'Жен.' not in provider._data['gender']
Exemple #2
0
    def test_override_locale(self, locale, new_locale):
        provider = Person(locale)
        assert Locale(provider.locale) == locale

        with provider.override_locale(new_locale):
            assert "Жен." in provider._data["gender"]
            assert Locale(provider.locale) == new_locale

        assert Locale(provider.locale) == locale
        assert "Жен." not in provider._data["gender"]

        del provider.locale
        with pytest.raises(ValueError):
            with provider.override_locale(new_locale):
                pass
def generate():
    def random_date(start, end):
        delta = end - start
        int_delta = (delta.days * 24 * 60 * 60) + delta.seconds
        random_second = randrange(int_delta)
        return start + timedelta(seconds=random_second)

    startDate = datetime.datetime(1995, 1, 1)
    endDate = datetime.datetime.now()

    # to_date('07-JUN-16','DD-MON-RR')

    template = Template(
        "Insert into EMPLOYEES (EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE,HIRE_DATE,MANAGER_ID,JOB_TITLE)"
        " values ($EMPLOYEE_ID,'$FIRST_NAME','$LAST_NAME','$EMAIL','$PHONE',$HIRE_DATE,$MANAGER_ID,'$JOB_TITLE');"
    )
    inserts = []
    counter = 200
    job_titles = [
        'Stock Clerk', 'Accountant', 'Sales Manager', 'Sales Representative',
        'Shipping Clerk'
    ]
    initial_managers = [48]

    person = Person('en')

    for index in range(counter, 25000, 1):
        tmp_job_title = random.choice(job_titles)
        if str(tmp_job_title).__contains__('Manager'):
            initial_managers.append(index)

        tmp_date = random_date(startDate, endDate)
        # tmp_month = calendar.month_abbr[tmp_date.month]
        # tmp_month = tmp_month.__str__()[:3]
        tmp_month = tmp_date.month.__str__()
        tmp_day = tmp_date.day.__str__()
        tmp_year = tmp_date.year.__str__()

        dates = "to_date('" + tmp_year + '-' + tmp_month + '-' + tmp_day + "', 'YYYY-MM-DD' )"

        inserts.append(
            template.substitute(EMPLOYEE_ID=index,
                                FIRST_NAME=person.name().replace("'", "''"),
                                LAST_NAME=person.last_name().replace(
                                    "'", "''"),
                                EMAIL=person.email().replace("'", "''"),
                                PHONE=person.telephone(),
                                HIRE_DATE=dates,
                                MANAGER_ID=random.choice(initial_managers),
                                JOB_TITLE=random.choice(job_titles)))

    inserts_file = open('result_scripts/employees.sql', 'w', encoding='utf-8')
    inserts_file.writelines('\n'.join(inserts))
    inserts_file.close()
Exemple #4
0
from collections import namedtuple

from mimesis.providers import Person as PersonGenerator
from mimesis.enums import Gender

person = PersonGenerator('en')

Person = namedtuple('Person', 'title surname name email username password')

if __name__ == '__main__':
    with open('users.txt', 'w') as file:
        for i in range(20):
            gender = Gender.FEMALE if i % 2 == 0 else Gender.MALE
            person_ = {
                'id': i,
                'title': person.title(gender),
                'surname': person.surname(gender),
                'name': person.name(gender),
                'email': person.email(),
                'username': person.username(),
                'password': person.password()
            }

            file.write(repr(person_))
            file.write('\n')

with open('users.txt') as file:
    users = [eval(row) for row in file.readlines()]

print(users)
Exemple #5
0
 def test_override_missing_locale_argument(self):
     provider = Person(Locale.EN)
     with pytest.raises(TypeError):
         with provider.override_locale():
             pass
Exemple #6
0
Checker.INFO = "vulns: 1"

RUSTPORT = 7878
NotificationApiPort = 5000

rustClient = RustClient(RUSTPORT, 3)
notificationApiClient = NotificationApiClient("10.10.10.99",
                                              NotificationApiPort, 3)

IMAGE_WIDTH = 1000
IMAGE_HEIGHT = 1000

PIXELS_WITH_FLAG = [(1088, 223), (992, 283), (1020, 172), (1066, 353),
                    (974, 636), (982, 570), (1042, 497), (1055, 420)]

PERSON = Person('en')
CRYPTO = Cryptographic()
STRUCTURE = Structure('en')
Internet = Internet('en')
ADDRESS = Address('en')


def generate_random_name():
    return random.choice([
        ADDRESS.region(),
        PERSON.full_name(),
        CRYPTO.mnemonic_phrase(),
        ADDRESS.country()
    ])