Esempio n. 1
0
    def setUp(self):
        with self.schema().create("users") as table:
            table.increments("id")
            table.string("name").unique()
            table.string("email").unique()
            table.boolean("admin").default(True)
            table.timestamps()

        with self.schema().create("posts") as table:
            table.increments("id")
            table.integer("user_id")
            table.string("title").unique()
            table.text("content").unique()
            table.timestamps()

            table.foreign("user_id").references("id").on("users")

        self.factory = Factory()

        @self.factory.define(User)
        def users_factory(faker):
            return {"name": faker.name(), "email": faker.email(), "admin": False}

        @self.factory.define(User, "admin")
        def users_factory(faker):
            attributes = self.factory.raw(User)

            attributes.update({"admin": True})

            return attributes

        @self.factory.define(Post)
        def posts_factory(faker):
            return {"title": faker.sentence(), "content": faker.text()}
Esempio n. 2
0
    def setUp(self):
        from wsgi import container

        self.container = container
        self._with_subdomains = False

        self.acting_user = False
        self.factory = Factory()
        self.withoutExceptionHandling()
        self.withoutCsrf()
        if not self._transaction:
            self.startTransaction()
            if hasattr(self, "setUpFactories"):
                self.setUpFactories()

        if self.sqlite and env("DB_CONNECTION") != "sqlite":
            raise Exception(
                "Cannot run tests without using the 'sqlite' database.")

        if not self.transactions and self.refreshes_database:
            self.refreshDatabase()

        self.route_middleware = False
        self.http_middleware = False
        self.headers = {}
Esempio n. 3
0
    def setUp(self):
        from wsgi import container
        self.container = container
        self.acting_user = False
        self.factory = Factory()
        self.withoutExceptionHandling()
        self.withoutCsrf()
        if not self._transaction:
            self.startTransaction()
            if hasattr(self, 'setUpFactories'):
                self.setUpFactories()

        if self.sqlite and env('DB_CONNECTION') != 'sqlite':
            raise Exception("Cannot run tests without using the 'sqlite' database.")

        if not self.transactions and self.refreshes_database:
            self.refreshDatabase()
Esempio n. 4
0
    def setUp(self):
        with self.schema().create('users') as table:
            table.increments('id')
            table.string('name').unique()
            table.string('email').unique()
            table.boolean('admin').default(True)
            table.timestamps()

        with self.schema().create('posts') as table:
            table.increments('id')
            table.integer('user_id')
            table.string('title').unique()
            table.text('content').unique()
            table.timestamps()

            table.foreign('user_id').references('id').on('users')

        self.factory = Factory()

        @self.factory.define(User)
        def users_factory(faker):
            return {
                'name': faker.name(),
                'email': faker.email(),
                'admin': False
            }

        @self.factory.define(User, 'admin')
        def users_factory(faker):
            attributes = self.factory.raw(User)

            attributes.update({'admin': True})

            return attributes

        @self.factory.define(Post)
        def posts_factory(faker):
            return {
                'title': faker.sentence(),
                'content': faker.text()
            }
Esempio n. 5
0
from orator.orm import Factory
from app.User import User
from app.Car import Car
from app.Customer import Customer
from app.Engine import Engine
from app.ServiceHistory import ServiceHistory

factory = Factory()


def users_factory(faker):
    return {
        "name": faker.name(),
        "email": faker.email(),
        "password":
        "******",  # == 'secret'
    }


def customers_factory(faker):
    return {}


def cars_factory(faker):
    return {
        "make": faker.name(),
        "model": faker.company(),
        "year": faker.pyint(),
        "color": faker.safe_color_name(),
        "engine": faker.catch_phrase(),
        "mileage": faker.pyint(min_value=10, max_value=200000),