Esempio n. 1
0
def genarate_posts(start_idx, number_of_post):
    """ Genarate more post """
    for i in range(number_of_post):
        id = 'abc' + str(i + start_idx)
        user_id = random.randint(102, 255)
        source = ''
        if i % 3 == 1:
            source = 'group:' + str(random.randint(123, 456))
        elif i % 3 == 2:
            source = 'page:' + str(random.randint(234, 567))
        else:
            source = ''
        content = lorem.paragraph()
        create_time = calendar.timegm(time.gmtime()) + i
        if i % 2:
            target = 'friends'
        else:
            target = 'public'

        post = {
            'id': id,
            'user_id': user_id,
            'source': source,
            'content': content,
            'media': '',
            'create_time': create_time,
            'target': target,
        }

        print(json.dumps(post))
        r = requests.post(url=API_ENDPOINT, json=post)
        print(r.status_code, r.reason)
Esempio n. 2
0
def products_generate_descriptions():
    print("Generating random lorem descriptions for products.")
    doc_ref = store.collection("products").stream()

    for doc in doc_ref:
        d = doc.to_dict()
        d["description"] = lorem.paragraph()
        store.collection("products").document(doc.id).set(d)
        prod_ids.append(doc.id)
    print("Done!\n")
Esempio n. 3
0
def RandomParagraph():
    yield ['text,\n']
    yield '<p>'
    p = lorem.paragraph().split(" ")
    # =< 10% of the paragraph will have links
    num_of_links = (int) (0.10 * len(p))
    for _ in range(num_of_links):
        p[randint(len(p))] = f'<a href="#">{Lorem(5)}</a>'
    yield ' '.join(p)
    yield '</p>'
Esempio n. 4
0
def main(words, s):
    """Console script for lorem."""
    if words:
        words = int(words)
        click.echo(lorem.words(words))

    # Returns a lorem ipsum sentence
    elif s:
        click.echo(lorem.sentence())

    # Returns a lorem ipsum paragraph by default
    else:
        click.echo(lorem.paragraph())
Esempio n. 5
0
 def handle(self, *args, **options):
     for premise in Premises.objects.all():
         premise.description = lorem.paragraph()
         premise.save()
Esempio n. 6
0
#pip install lorem-text
from lorem_text import lorem
print('\n\n',lorem.paragraph(),'\n')
print(lorem.sentence(),'\nDone')
Esempio n. 7
0
# instalar biblioteca
# pip install lorem-text

from lorem_text import lorem

# Gere um único parágrafo
print(lorem.paragraph())
#Saida: Sapiente accusamus aliquid quas, magnam illo quas culpa facere assumenda,
# voluptatum vero dicta numquam in dolorum necessitatibus possimus obcaecati.

# Para frases geradas aleatoriamente de texto lorem ipsum em que a
# primeira palavra é maiúscula e a frase termina em um ponto ou ponto de interrogação:
print(lorem.sentence())
# Saida:
# Cumque tempore aperiam, aliquid distinctio unde perferendis exercitationem nulla deserunt,
# cum unde quisquam corporis dolore dignissimos architecto commodi sapiente expedita esse,
# aliquam est sint ex alias cum magnam adipisci numquam quidem saepe dicta?
Esempio n. 8
0
def generate_run_results(start_date: datetime, num_tests: int):
    _test_suites = []
    cur_time = start_date
    start_time = cur_time
    for suite_i in range(randint(4, 25)):
        cur_time += timedelta(seconds=randint(0, 4))  # overhead
        cur_time = cur_time.replace(microsecond=0)
        elapsed_suite = 0
        test_cases = []
        for case_i in range(int(num_tests / 10)):
            elapsed = randint(5, 60 * 10)
            elapsed_suite += elapsed
            cur_time += timedelta(seconds=elapsed)

            # Add some randomization
            choices = ['pass'] * randint(10, 70) + ['error'] * randint(
                0, 20) + ['skipped'] * randint(0, 5) + ['failure'] * randint(
                    0, 5)
            while len(choices) < 100:
                choices.append(
                    random.choice(('pass', 'error', 'skipped', 'failure')))
            status = random.choice(choices)

            properties = {}
            for i in range(randint(0, 10)):
                properties[f'key{i}'] = f'value{i}'

            test_case = TestCase(
                system_err=[
                    Pair(tag='system-err', text=lorem.words(randint(1, 5)))
                    for _ in range(randint(0, 4))
                ],
                system_out=[
                    Pair(tag='system-out', text=lorem.words(randint(1, 5)))
                    for _ in range(randint(0, 4))
                ],
                properties=properties,
                skipped=[] if status != 'skipped' else [
                    SimpleField(tag='skipped',
                                type=lorem.words(1),
                                message=lorem.words(randint(2, 15)),
                                text=lorem.words(randint(1, 5)))
                    for _ in range(randint(0, 4))
                ],
                error=[] if status != 'error' else [
                    SimpleField(tag='error',
                                type=lorem.words(1),
                                message=lorem.words(randint(2, 15)),
                                text=lorem.words(randint(1, 5)))
                    for _ in range(randint(0, 4))
                ],
                failure=[] if status != 'failure' else [
                    SimpleField(tag='failure',
                                type=lorem.words(1),
                                message=lorem.words(randint(2, 15)),
                                text=lorem.words(randint(1, 5)))
                    for _ in range(randint(0, 4))
                ],
                rerun_failure=[],
                rerun_error=[],
                flaky_failure=[],
                flaky_error=[],
                attributes={
                    'name': f'test_case_{suite_i}_{case_i}',
                    'description': lorem.paragraph(),
                    'time': f'{elapsed:.3f}',
                    'classname':
                    f'my.package.test_case_class_{suite_i}_{case_i}',
                    'group': f'Group {suite_i}_{case_i}',
                    'file': f'test_suites/test_suite{suite_i}.py',
                    'line': 1 + suite_i * 100 + case_i,
                })
            test_cases.append(test_case)

        properties = {}
        for i in range(randint(0, 5)):
            properties[f'key{i}'] = f'value{i}'
        test_suite = TestSuite(
            system_err=[
                Pair(tag='system-err', text=lorem.words(randint(2, 10)))
                for _ in range(randint(0, 4))
            ],
            system_out=[
                Pair(tag='system-out', text=lorem.words(randint(2, 10)))
                for _ in range(randint(0, 4))
            ],
            properties=properties,
            testcases=test_cases,
            attributes={
                'name': f'test_suite_{suite_i}',
                'description': lorem.words(randint(2, 10)),
                'tests': str(len(test_cases)),
                'failures':
                str(len([e for e in test_cases if len(e.failure) > 0])),
                'errors': str(len([e for e in test_cases
                                   if len(e.error) > 0])),
                'group': f'Group {suite_i}',
                'time': f'{elapsed_suite:.3f}',
                'skipped':
                str(len([e for e in test_cases if len(e.skipped) > 0])),
                'timestamp': cur_time.isoformat(),
                'hostname': 'localhost',
                'id': str(suite_i + 1),
                'package': f'my.package{suite_i}',
                'file': f'test_suites/test_suite{suite_i}.py',
                'log': f'log_{suite_i}.log',
                'url': f'http://some_url/suite{suite_i}',
                'version': 'v1',
            })
        _test_suites.append(test_suite)

    time = (cur_time - start_time).total_seconds()
    test_suites = etree.Element(
        'testsuites',
        attrib={
            'name':
            'test_run',
            'time':
            f'{time:.3f}',
            'tests':
            str(sum([len(e.testcases) for e in _test_suites])),
            'failures':
            str(sum([int(e.attributes['failures']) for e in _test_suites])),
            'errors':
            str(sum([int(e.attributes['errors']) for e in _test_suites])),
        })
    for ts in _test_suites:
        test_suites.append(ts.serialize())

    return test_suites
Esempio n. 9
0
 def test_paragraph(self):
     para = lorem.paragraph()
     size = len(re.split(",", para))
     self.assertTrue(2 <= size <= 15)
 def get_random_paragraph():
     return lorem.paragraph()
Esempio n. 11
0
        response = requests.post(f'{host}/users/login',
                                 data={
                                     'login': f'login_{i}',
                                     'password': '******',
                                 })
        users.append({'token': response.json()['token'], 'id': user_id})

    for user in users:
        number_of_posts = random.randint(1, max_posts_per_user)
        headers = {'Authorization': user['token']}
        for i in range(number_of_posts):
            response = requests.post(
                f'{host}/posts/',
                data={
                    'title': 'Post {i} by user {user[id]}',
                    'content': lorem.paragraph(),
                },
                headers=headers,
            )
            post = response.json()
            posts.append(post)

    for user in users:
        number_of_likes = random.randint(1, max_likes_per_user)
        headers = {'Authorization': user['token']}
        for i in range(number_of_likes):
            post_id = random.choice(posts)['id']
            requests.post(
                f'{host}/posts/{post_id}/like/',
                headers=headers,
            )
Esempio n. 12
0
# for nav bar styling
import dash_bootstrap_components as dbc

from components import titleBar, navBar, body, footer

# for random paragraphs
from lorem_text import lorem

firstLineContent = html.P("""
	Welcome to our news page. Randomly generated Lorem Ipsum paragrams follows.
""")

pageContent = html.Div([
    firstLineContent,
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph()),
    html.P(lorem.paragraph())
])


def getContent():