def create_test_file(file_info):
    """
    Creates random files to run the test on,
    and return the correct amount of matches.
    """

    txt = lorem.paragraphs(5)
    count = len(re.findall(EXP, txt))
    f = open('{}/{}'.format(TEST_FOLDER_PATH, file_info[0]), 'w')
    f.write(txt)
    f.close()
    return count
def create_test_files(test_info):
    """
    Creates random files to run the test on,
    and return the correct amount of matches.
    """

    match_count = 0
    for counter in range(test_info[1]):
        txt = lorem.paragraphs(5)
        match_count += len(re.findall(EXP, txt))
        f = open(
            '{}/{}'.format(TEST_FOLDER_PATH,
                           test_info[0] + '_' + str(counter + 1)), 'w')
        f.write(txt)
        f.close()
    return match_count
Beispiel #3
0
from lorem_text import lorem

TITLE = 'Index'

CONTENT = [item for item in lorem.paragraphs(1).split('\n') if len(item) > 4]
def createComponents():
    """
    Hier werden die Komponenten des Dokumentes erstellt
    Die Reihenfolge ist wichtig!
    :return: Komponenten als Liste
    """

    # TODO: Die richtigen Daten einfügen und nutzen

    # Liste der Komponenten wird initialisiert
    elements = []

    # Das Adressfeld wird initialisiert (muss immer am Anfang stehen!)
    # Die Daten dafür müssen im content dict angepasst werden
    elements.append(HtmlContent(element_type=HtmlElementType.ADDRESSFIELD))

    # Ein Betreff  wird eingefügt
    elements.append(
        HtmlContent(title=lorem.words(2),
                    element_type=HtmlElementType.SUBJECT))

    # Generische Textabsätze werden mit Überschrift hinzugefügt
    for i in range(0, 5):
        title = lorem.words(4)
        content = lorem.paragraphs(2)
        elements.append(
            HtmlContent(title=title,
                        content=content,
                        element_type=HtmlElementType.PARAGRAPH))

    # Die Zeilen einer Tabelle werden initialisiert
    table_content = []
    for i in range(0, 10):
        title = lorem.words(2)
        content = lorem.words(5)
        # Die Zeilen werden befüllt
        table_content.append(
            HtmlContent(title=title,
                        content=content,
                        element_type=HtmlElementType.TABLEROW))
    # Die Zeilen werden einer Tabelle hinzugefügt und die den Komponenten
    elements.append(
        HtmlContent(title="Testtabelle",
                    content=table_content,
                    element_type=HtmlElementType.TABLE))

    # Eine Unter-Überschrift wurd hinzugefügt
    elements.append(
        HtmlContent(title=lorem.words(2),
                    element_type=HtmlElementType.HEADING))

    # Es werden Absätze mit dem Titel links und dem Inhalt rechts hinzugefügt
    for i in range(0, 5):
        title = lorem.words(2)
        content = lorem.paragraphs(1)
        elements.append(
            HtmlContent(title=title,
                        content=content,
                        element_type=HtmlElementType.SIDEPARAGRAPH))

    # Absatz vor den Unterschriften und Unterschriften
    elements.append(
        HtmlContent(content=lorem.paragraphs(1),
                    element_type=HtmlElementType.PARAGRAPH))
    elements.append(HtmlContent(element_type=HtmlElementType.SIGNATURES))

    return elements
Beispiel #5
0
def init_test_data():
	from . import models
	session = models.db.session
	print("Filling database with test data...", flush=True)

	user1 = models.User(name="Larrytest", external_id=65)
	user2 = models.User(name="Larry", external_id=872)

	session.add(user1)
	session.add(user2)
	session.commit()

	tags = dict()
	for tag in ("openclonk-9", ".scenario", ".objects", "multiplayer", "advertisement", "bundle", "test",
				"race", "puzzle", "adventure", "melee"):
		t = models.Tag(title=tag)
		tags[tag] = t
		session.add(t)
	session.commit()

	yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
	last_week = datetime.datetime.now() - datetime.timedelta(days=7)

	packages = []
	packages.append(models.Package(title="Caedes", author="Zapper, KKenny", description="The very first and the very last. At least 50 chars.", owner=user1.id,
									long_description=lorem.paragraphs(5)))
	for tag in ("openclonk-9", ".objects", ".scenario", "multiplayer", "test"):
		packages[-1].tags.append(tags[tag])
	packages.append(models.Package(title="Blubb", author="Nicht die Mama", description="I don't know what I am doing. At least 50 chars...", owner=user1.id, modification_date=yesterday,
									long_description=lorem.paragraphs(2)))
	for tag in (".scenario", "race", "puzzle", "adventure", "melee"):
		packages[-1].tags.append(tags[tag])
	packages.append(models.Package(title="Larry", author="Kanibal", description="Database for mods (but it no work). At least 50 chars.", owner=user2.id, modification_date=yesterday,
									long_description=lorem.paragraphs(20)))
	for tag in ("advertisement", "test"):
		packages[-1].tags.append(tags[tag])
	packages.append(models.Package(title="Caedesblubb", author="Noone", description="Bundles Caedes and Blubb. At least 50 chars. At least 50 chars.", owner=user1.id, modification_date=last_week,
									long_description=lorem.paragraphs(1)))
	for tag in ("bundle", "openclonk-9", ".scenario", "test"):
		packages[-1].tags.append(tags[tag])
	for i in range(2):
		packages[-1].dependencies.append(models.PackageDependencies(packages[i]))
	packages.append(models.Package(title="戦争と平和",
		description="Unicode test. And also maximum description length test to see whether it looks fine in the interfaces because it should. Otherwise that would suck bad",
		owner=user2.id, modification_date=last_week))

	files = [os.path.join(models.app.config.get("TEST_DATA_PATH"), file) for file in os.listdir(models.app.config.get("TEST_DATA_PATH"))]

	with tempfile.TemporaryDirectory() as f:
		for idx, file in enumerate(files):
			target_file = f + "/" + file.split("/")[-1]
			shutil.copy(file, target_file)

			package = packages[int(idx/2)]
			res = models.Resource(package=package, owner=package.owner)
			session.add(res)
			try:
				res.init_from_path(target_file)
				print((target_file, res.sha1))
			except ValueError as e:
				print(str(e))
	session.commit()

	for p in packages:
		p.update_search_text()
		session.add(p)
	session.commit()
# import the lorem module from lorem_text
from lorem_text import lorem             

# Provide the number of paragrpahs you want
paragraph_length = int(input("Enter the length of paragraph you want: "))

# Store it in a variable, lorem.paragraphs() is used to generate the paragraphs
se = lorem.paragraphs(paragraph_length)

# Finally print the paragraphs
print(se)
# the result will be in lorem style
Beispiel #7
0
 def test_paragraphs(self):
     paras = lorem.paragraphs(2)
     size = len(paras)
     self.assertTrue(size >= 10)