Ejemplo n.º 1
0
 def generate_comment(func_author, func_post):
     return Comment(
         body=lorem_ipsum.paragraphs(),
         created=date.date(past=True),
         authors=func_author(),
         post=func_post()
     )
Ejemplo n.º 2
0
 def generate_post(func_author):
     return Post(
         title=lorem_ipsum.title(),
         body=lorem_ipsum.paragraphs(),
         created=date.date(),
         author=func_author(),
     )
Ejemplo n.º 3
0
def create_random_product():
    title = lorem_ipsum.words(randint(1, 5))
    description = lorem_ipsum.paragraphs(randint(1, 3), html=True)
    cost = randint(1.00, 100.00)
    available = True
    stock_qty = randint(1, 20)

    return Product(title=title, description=description, cost=cost, available=available, stock_qty=stock_qty)
Ejemplo n.º 4
0
 def generate_user(i):
     return User(
         name="%s%s" % (internet.user_name(), i),
         password=basic.text(8, at_least=8, spaces=False),
         email=internet.email_address(),
         phone=basic.text(11, at_least=11, lowercase=False, uppercase=False, spaces=False),
         info=lorem_ipsum.paragraphs(),
         photo="%s.jpg" % i,
         uuid=uuid4().hex,
     )
Ejemplo n.º 5
0
 def generate_article(func_author):
     return Article(title=lorem_ipsum.title(),
                    body=lorem_ipsum.paragraphs(),
                    created_time=date.date(past=True),
                    author=func_author())
Ejemplo n.º 6
0
 def generate_comment(func_author, func_article):
     return Comment(body=lorem_ipsum.paragraphs(),
                    created_time=date.date(past=True),
                    author=func_author(),
                    article=func_article())
Ejemplo n.º 7
0
from os import path, mkdir
from helper import test_app_path, clean_pages
from forgery_py import lorem_ipsum as lorem, date
import random

_title = lambda: 'title: "%s"' % lorem.words(random.randint(2, 5))
_file_name = lambda: '%s_%s' % (lorem.word(), lorem.word())
_summary = lambda: 'summary: "%s"' % lorem.sentence()
_body = lambda: lorem.paragraphs(random.randint(5, 20))
_tags = lambda: 'tags: "%s"' % ','.join(lorem.words(random.randint(2, 5), as_list=True))
_pub = lambda: 'date: %s 00:00:00' % date.date(past=True)


class DataMocks(object):
    def page(self, file_name):
        return self.write_page(file_name, [_title(), _summary(), '', _body()])

    def post(self, file_name):
        return self.write_page(file_name, [_title(), _summary(), _tags(), _pub(), '', _body()], root='pages/posts')


    def write_page(self, file_name, lines, root='pages'):
        page_folder = path.join(test_app_path, root, file_name)
        if not path.exists(page_folder):
            mkdir(page_folder)

        with open(path.join(test_app_path, root, file_name + '.md'), 'w') as file:
            file.write('\n'.join(lines))
        return self

    def index(self):
Ejemplo n.º 8
0
 def generate_post(func_author):
     return Post(title=lorem_ipsum.title(),
                 body=lorem_ipsum.paragraphs(),
                 created=date.date(),
                 author=func_author())
Ejemplo n.º 9
0
 def generate_comment(func_author, func_post):
     return Comment(body=lorem_ipsum.paragraphs(),
                    created=date.date(past=True),
                    author=func_author(),
                    post=func_post())