Пример #1
0
    def setup_method(self, test_method):

        self.cidade = Recipe(Cidade,
            nome='São José dos Campos',
        )

        self.regiao = Recipe(Regiao,
            nome='Oeste',
            cidade=foreign_key(self.cidade),
        )

        self.bairro = Recipe(Bairro,
            nome='Aquarius',
            regiao=foreign_key(self.regiao),
        )

        self.proprietario = Recipe(Proprietario,
            nome='Roger Waters',
            fone='12998001002',
        )

        self.casa = Recipe(Imovel,
            proprietario=foreign_key(self.proprietario),
            tipo_imovel=Imovel.TIPO_IMOVEL.casa,
            dormitorios=3,
            cidade=foreign_key(self.cidade),
            bairro=foreign_key(self.bairro),
        )
Пример #2
0
    def setUpClass(cls):
        # clear db
        models.User.objects.all().delete()
        models.Activity.objects.all().delete()

        cls.assertStrEqual = lambda cls, x, y: cls.assertEqual(str(x), str(y))

        employee = recipe.Recipe(models.Employee,
                                 id=1,
                                 first_name='Jan',
                                 last_name='Wójt')
        company = recipe.Recipe(models.CoffeeCompany,
                                id=2,
                                full_name='Kawa')
        activity1 = recipe.Recipe(models.Activity,
                                  id=1,
                                  creator=recipe.foreign_key(employee),
                                  target=recipe.foreign_key(company),
                                  content='Jan Wójt drinked coffee from Kawa')
        activity2 = recipe.Recipe(models.Activity,
                                  id=2,
                                  creator=recipe.foreign_key(company),
                                  target=recipe.foreign_key(employee),
                                  content='Kawa delivered product to Jan Wójt')

        employee.make()
        company.make()
        activity1.make()
        activity2.make()
Пример #3
0
class PowerRecipes(ConversationRecipes):
    given_bridge_power = Recipe(GivenBridgePower, **_power_kwargs)
    given_minority_power = Recipe(GivenMinorityPower, **_power_kwargs)
    comment_promotion = Recipe(
        CommentPromotion,
        comment=foreign_key(recipe.comment),
        promoter=foreign_key(
            recipe.author.extend(email="*****@*****.**")),
    )

    @pytest.fixture
    def data(self, request):
        data = super().data(request)
        return data
Пример #4
0
 def setUp(self):
     self.commit = Recipe(Commit, hash='Commit1')
     self.modification_ucloc = Recipe(Modification,
                                      path='test.java',
                                      added=2,
                                      removed=1,
                                      commit=foreign_key(self.commit))
Пример #5
0
 def test_returns_a_callable(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     method = foreign_key(number_recipe)
     self.assertTrue(callable(method))
     self.assertTrue(method.im_self, number_recipe)
Пример #6
0
class BoardRecipes(Base):
    board = Recipe(
        Board,
        slug='board-slug',
        title='Title',
        description='Description',
        owner=foreign_key(Base.author),
    )
Пример #7
0
    def test_prepare_recipe_with_foreign_key(self):
        person_recipe = Recipe(Person, name='John Doe')
        dog_recipe = Recipe(Dog,
            owner=foreign_key(person_recipe),
        )
        dog = dog_recipe.prepare()

        self.assertIsNone(dog.id)
        self.assertIsNone(dog.owner.id)
Пример #8
0
    def test_prepare_recipe_with_foreign_key(self):
        person_recipe = Recipe(Person, name='John Doe')
        dog_recipe = Recipe(
            Dog,
            owner=foreign_key(person_recipe),
        )
        dog = dog_recipe.prepare()

        self.assertIsNone(dog.id)
        self.assertIsNone(dog.owner.id)
Пример #9
0
class BoardRecipes(Base):
    board = Recipe(Board,
                   slug="board-slug",
                   title="Title",
                   description="Description",
                   owner=foreign_key(Base.author))

    def get_data(self, request):
        data = super().get_data(request)
        board = self.board.make(owner=data.author)
        return record(data, board=board)
Пример #10
0
 def setup_method(self, test_method):
     criar_dependencia_recipe_imovel(self)
     self.recipe_bairro_imovel_sj = Recipe(
         BairroComImoveis,
         cidade=foreign_key(self.cidade),
         bairro=foreign_key(self.bairro),
         regiao=foreign_key(self.regiao),
         tipo_imovel=Imovel.TIPO_IMOVEL.apartamento)
     self.cidade_macae = Recipe(Cidade, nome="Macae")
     self.bairro_aeroporto = Recipe(Bairro, nome="Aeroporto")
     self.recipe_bairro_imovel_macae = Recipe(
         BairroComImoveis,
         cidade=foreign_key(self.cidade_macae),
         bairro=foreign_key(self.bairro_aeroporto),
         regiao=foreign_key(self.regiao),
         tipo_imovel=Imovel.TIPO_IMOVEL.apartamento)
Пример #11
0
    def init_recipes(self):
        self._user_recipe = Recipe(
            User,
            first_name=self.faker.first_name,
            email=self.faker.email,
            password=self.faker.password,
        )

        self.auth_user = self._user_recipe.make()

        self._company_recipe = Recipe(Company,
                                      name=self.faker.company,
                                      company_id=seq(1),
                                      website=self.faker.uri)

        self._review_recipe = Recipe(Review,
                                     rating=5,
                                     title=self.faker.sentence,
                                     summary=self.faker.paragraph,
                                     ip_address=self.faker.ipv4,
                                     company=foreign_key(self._company_recipe),
                                     reviewer=self.get_auth_user)
from model_mommy.recipe import Recipe, seq, foreign_key
from ..models import Provider, ProviderAllocation, OutOfHoursRota, Staff, Feedback, CSVUpload

provider = Recipe(Provider, name=seq("Name"))

staff = Recipe(Staff)

outofhoursrota = Recipe(OutOfHoursRota)

provider_allocation = Recipe(ProviderAllocation)

feedback = Recipe(Feedback, created_by=foreign_key(staff))

csvupload_determination = Recipe(
    CSVUpload,
    body=[
        u"2222222",
        u"0000",
        u"1A111A",
        u"A",
        u"Corgi",
        u"01/01/1901",
        u"D",
        u"F",
        u"1",
        u"",
        u"",
        u"SW1A 1AA",
        u"",
        u"SWAG",
        u"YOLO",
Пример #13
0
from unipath import Path

from django.conf import settings
from django.core.files import File

from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models


django_file_path = Path(settings.APP_DIR, "grunt/tests/media/test-audio.wav")
assert django_file_path.exists()
django_file = File(open(django_file_path, "rb"))

chain = Recipe(grunt_models.Chain, name="mommy_chain")

seed = Recipe(grunt_models.Message, chain=foreign_key(chain), audio=django_file)

recording = Recipe(grunt_models.Message, chain=foreign_key(chain), parent=foreign_key(seed), audio=django_file)

survey = Recipe(ratings_models.Survey)

empty_question = Recipe(
    ratings_models.Question, survey=foreign_key(survey), given=foreign_key(recording), answer=foreign_key(seed)
)

response = Recipe(ratings_models.Response, question=foreign_key(empty_question), selection=foreign_key(seed))
from model_mommy.recipe import Recipe, seq, foreign_key
from account.models import Team, Role
from django.contrib.auth.models import User


user = Recipe(
    User,
    username=seq('fake_username'),
    email=seq('fake_user_mail')
)


role = Recipe(
    Role,
    name=seq('fake_role')
)


team = Recipe(
    Team,
    email=seq('fake_email'),
    contacts=seq('fake_contact'),
    role=foreign_key(role)
)
Пример #15
0
serial_numbers_by = Recipe(DummyDefaultFieldsModel,
    default_decimal_field = seq(Decimal('20.1'), increment_by=Decimal('2.4')),
    default_int_field = seq(10, increment_by=3),
    default_float_field = seq(1.23, increment_by=1.8)
)

serial_datetime = Recipe(DummyDefaultFieldsModel,
    default_date_field = seq(TEST_TIME.date(), timedelta(days=1)),
    default_date_time_field = seq(TEST_TIME, timedelta(hours=3)),
    default_time_field = seq(TEST_TIME.time(), timedelta(seconds=15))
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)

homeless_dog = Recipe(Dog,
    breed = 'Pug',
)

other_dog = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key('person')
)

dog_with_friends = dog.extend(
    friends_with=related(dog, dog),
)
Пример #16
0
 def test_foreign_key_method_returns_a_recipe_foreign_key_object(self):
     number_recipe = Recipe(DummyNumbersModel, float_field=1.6)
     obj = foreign_key(number_recipe)
     self.assertIsInstance(obj, RecipeForeignKey)
Пример #17
0
    email = '*****@*****.**',
    first_name = 'reza',
    last_name = 'khazali',
    password = '******'
)

doctorDegree = Recipe(
    DoctorDegree,
    university='tehran2',
    endOfGraduate='1395',
    degree='GL',
    degreeTitle='beauty1',
)

doctor = Recipe(
    Doctor,
    user = foreign_key(user),
    doctorDegree = foreign_key(doctorDegree),
)

insurance = Recipe(
    Insurance,
    doctor = foreign_key(doctor),
    name = 'my_social_insurance'
)

office = Recipe(
    Office,
    address =  'faffa',
    telephone = '091230948123',
)
Пример #18
0
#: This means that it is right at the beginning for a period created
#: with the :obj:`.period_old` recipe.
#:
#: The period (parentnode) defaults to a period created with :obj:`.period_old`.
#:
#: Example usage::
#:
#:    assignment = mommy.make_recipe('devilry.apps.core.assignment_oldperiod_start')
#:
#:
#: See also :obj:`.assignment_oldperiod_middle` :obj:`.assignment_oldperiod_end`
assignment_oldperiod_start = recipe.Recipe(
    Assignment,
    publishing_time=OLD_PERIOD_START,
    first_deadline=ASSIGNMENT_OLDPERIOD_START_FIRST_DEADLINE,
    parentnode=recipe.foreign_key(period_old)
)


#: Use this Recipe to create an Assignment that has ``publishing_time``
#: set to ``1500-01-01 00:00`` and ``first_deadline`` set to
#: ``1500-01-15 23:59``.
#:
#: The period (parentnode) defaults to
#: a period created with :obj:`.period_old`.
#:
#: Example usage::
#:
#:    assignment = mommy.make_recipe('devilry.apps.core.assignment_oldperiod_middle')
#:
#:
Пример #19
0
from model_mommy.recipe import Recipe, foreign_key, seq
from model_mommy import mommy

from .models import Zone, AddressRecord, CanonicalNameRecord, MailExchangeRecord, \
    NameServerRecord, TextRecord, ServiceRecord

# Dynamically import the mommy_recipe for the DOMAIN_MODEL
# If `DNS_MANAGER_DOMAIN_MODEL = 'vg.accounts.Domains'` then
# this is equivalent to: `from vg.account.mommy_recipes import domain`

t = settings.DNS_MANAGER_DOMAIN_MODEL.rsplit('.', 1)[0]
module = __import__(t + '.mommy_recipes', fromlist=['domain'])
domain = getattr(module, 'domain')

zone = Recipe(Zone, domain=foreign_key(domain))

address_record = Recipe(
    AddressRecord,
    zone=foreign_key(zone),
    ip=mommy.generators.gen_ipv4(),
)

cname_record = Recipe(CanonicalNameRecord, zone=foreign_key(zone))

mx_record = Recipe(MailExchangeRecord, zone=foreign_key(zone))

ns_record = Recipe(NameServerRecord, zone=foreign_key(zone))

text_record = Recipe(TextRecord,
                     zone=foreign_key(zone),
Пример #20
0
    'Евгений',
    'Александр',
]
last_names = [
    'Иванов', 'Попов', 'Михайлов', 'Столяров', 'Пономарев', 'Золотарев'
]
salaries = [
    100000,
    150000,
    200000,
    55000,
]

region = Recipe(Region, name=cycle(regions))

city = Recipe(City, name=cycle(cities), region=foreign_key(region))

employer = Recipe(
    Employer,
    name=cycle(employer_names),
    short_name=cycle(employer_short_names),
    city=foreign_key(city),
    site=seq('site.ru'),
    inn=seq('123456789'),
    phone=seq('8925601140'),
)


class Command(BaseCommand):
    def handle(self, *args, **options):
Пример #21
0
from django.conf import settings
from django.core.files import File

from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models

django_file_path = Path(settings.APP_DIR, 'grunt/tests/media/test-audio.wav')
assert django_file_path.exists()
django_file = File(open(django_file_path, 'rb'))

chain = Recipe(grunt_models.Chain, name='mommy_chain')

seed = Recipe(grunt_models.Message,
              chain=foreign_key(chain),
              audio=django_file)

recording = Recipe(grunt_models.Message,
                   chain=foreign_key(chain),
                   parent=foreign_key(seed),
                   audio=django_file)

question = Recipe(
    ratings_models.Question,
    # Needs to be a valid recording
    choices=related('seed', 'seed'),
    answer=foreign_key(seed))

response = Recipe(ratings_models.Response,
                  question=foreign_key(question),
Пример #22
0
    def setup_method(self, test_method):

        self.cidade = Recipe(
            Cidade,
            nome='São José dos Campos',
        )

        self.regiao = Recipe(
            Regiao,
            nome='Oeste',
            cidade=foreign_key(self.cidade),
        )

        self.bairro = Recipe(
            Bairro,
            nome='Aquarius',
            regiao=foreign_key(self.regiao),
        )

        self.condominio = Recipe(
            Condominio,
            cep='12120000',
            logradouro='Rua Tubarão Branco',
            numero='900',
            bairro=foreign_key(self.bairro),
            regiao=foreign_key(self.regiao),
            cidade=foreign_key(self.cidade),
        )

        self.proprietario = Recipe(
            Proprietario,
            nome='Roger Waters',
            fone='12998001002',
        )

        self.apartamento = Recipe(
            Imovel,
            proprietario=foreign_key(self.proprietario),
            tipo_imovel=Imovel.TIPO_IMOVEL.apartamento,
            dormitorios=2,
            condominio=foreign_key(self.condominio),
            cidade=foreign_key(self.cidade),
            bairro=foreign_key(self.bairro),
            complemento='Apto 14A',
        )

        self.casa = Recipe(
            Imovel,
            proprietario=foreign_key(self.proprietario),
            tipo_imovel=Imovel.TIPO_IMOVEL.casa,
            dormitorios=3,
            cidade=foreign_key(self.cidade),
            bairro=foreign_key(self.bairro),
        )
Пример #23
0
              email="*****@*****.**",
              )

# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_PC = Recipe(EventType, event_type="CL", subtype=seq("Pole level class"))
event_type_PP = Recipe(EventType, event_type="CL", subtype=seq("Pole practice"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))
event_type_OE = Recipe(EventType, event_type="EV", subtype=seq("Other event"))
event_type_OC = Recipe(EventType, event_type="CL", subtype=seq("Other class"))
event_type_RH = Recipe(EventType, event_type="RH", subtype=seq("Room hire"))

future_EV = Recipe(Event,
                      date=future,
                      event_type=foreign_key(event_type_OE))

future_WS = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_WS))

future_PC = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PC))
future_PP = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PP))
future_CL = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_OC))
future_RH = Recipe(Event,
Пример #24
0
from model_mommy.recipe import Recipe, foreign_key

# Relative imports of the 'app-name' package
from talks.models import Talk
from speakers.mommy_recipes import speaker_test_functional

talk_test_functional = Recipe(
    Talk,
    speaker=foreign_key(
        speaker_test_functional
    ),
    title=u'Talk to do test functional',
    slug=u'talk-to-do-test-functional',
    summary=u'test in everywhere',
)
Пример #25
0
 def test_not_accept_other_type(self):
     with self.assertRaises(TypeError) as c:
         foreign_key(2)
     exception = c.exception
     self.assertEqual(str(exception), 'Not a recipe')
Пример #26
0
import datetime

from faker import Faker
from model_mommy.recipe import foreign_key, Recipe, seq

from .. import models

faker = Faker("pt_BR")

assunto = Recipe(
    models.Assunto,
    nome=seq("Assunto "),
)

noticia = Recipe(
    models.Noticia,
    titulo=faker.sentence,
    corpo=faker.paragraph,
    resumo=faker.sentence,
    assunto=foreign_key(assunto)
)
Пример #27
0
from unipath import Path

from django.conf import settings
from django.core.files import File

from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models


django_file_path = Path(settings.APP_DIR, 'grunt/tests/media/test-audio.wav')
assert django_file_path.exists()
django_file = File(open(django_file_path, 'rb'))

chain = Recipe(grunt_models.Chain,
    name = 'mommy_chain')

seed = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    audio = django_file)
Пример #28
0
faker = Faker('pt_BR')

candidato = Recipe(models.Candidato,
                   nome=faker.name_male,
                   cpf=faker.cpf,
                   nascimento=faker.date_of_birth(minimum_age=17,
                                                  maximum_age=70),
                   nacionalidade=Nacionalidade.BRASILEIRA.name,
                   logradouro=faker.street_name,
                   numero_endereco=faker.building_number,
                   bairro=faker.bairro,
                   municipio=faker.city,
                   uf=faker.estado_sigla,
                   cep=faker.postcode,
                   email=faker.email,
                   user=foreign_key(base.tests.recipes.user))

curso_psct = curso_selecao.extend(formacao=cycle([
    Formacao.INTEGRADO.name,
    Formacao.SUBSEQUENTE.name,
]))

processo_inscricao = Recipe(models.ProcessoInscricao,
                            edital=foreign_key(edital),
                            multiplicador=5,
                            data_inicio=datetime.date.today,
                            data_encerramento=datetime.date.today)

curso_edital = Recipe(models.CursoEdital,
                      edital=foreign_key(edital),
                      curso=foreign_key(curso_psct))
Пример #29
0
from datetime import date
from model_mommy.recipe import Recipe, foreign_key, related, seq
from tests.models import TestCat, TestDog, TestPerson

# Here we define the model_mommy recipes for more semantic tests
# For more info go to: http://model-mommy.readthedocs.io/en/latest/recipes.html

test_dog = Recipe(TestDog, name=seq("Dog"), age=seq(1))

test_cat = Recipe(TestCat, name=seq("Cat"), hate_level=seq(1))

test_person = Recipe(TestPerson,
                     name=seq("Name"),
                     birth_date=date.today(),
                     dog=foreign_key(test_dog),
                     cats=related(test_cat, test_cat, test_cat))
Пример #30
0
#coding: utf-8

#ATTENTION: Recipes defined for testing purposes only
from model_mommy.recipe import Recipe, foreign_key
from model_mommy.models import Person, Dog

from datetime import date, datetime

person = Recipe(Person,
    name = 'John Doe',
    nickname = 'joe',
    age = 18,
    bio = 'Someone in the crowd',
    blog = 'http://joe.blogspot.com',
    wanted_games_qtd = 4,
    birthday = date.today(),
    appointment = datetime.now(),
    birth_time = datetime.now
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)
Пример #31
0
faker = Faker('pt_BR')

ies = Recipe(
    models.IES,
    codigo=seq(1),
    uf=faker.estado_sigla,
    nome=seq("Instituto Federal "),
    sigla=seq("IF"),
)

campus = Recipe(
    models.Campus,
    nome=seq("Campus "),
    sigla=seq("CP "),
    ies=foreign_key(ies),
    cidade__nome=faker.city,
    cidade__uf=faker.estado_sigla,
    endereco=faker.street_name,
    telefone=seq("83 9999 999"),
    url=faker.url,
)

curso = Recipe(
    models.Curso,
    nome=seq("Curso "),
    perfil_unificado=faker.sentence(nb_words=10),
)

curso_tecnico = curso.extend(nivel_formacao=choices.NivelFormacao.TECNICO.name)
Пример #32
0
def generate_duration():
    return random.randrange(1, 20)


def generate_duration_or_zero():
    if random.uniform(0, 10) > 8:
        return generate_duration()
    else:
        return 0


def generate_bool():
    return random.uniform(0, 1) > 0


def generate_color_hex():
    """
    See http://stackoverflow.com/a/14019260
    """
    def r():
        return random.randint(0, 255)

    return '#%02X%02X%02X' % (r(), r(), r())


UserRecipe = Recipe(get_user_model(), email=gen_email())
EmailAddressRecipe = Recipe(EmailAddress,
                            user=foreign_key(UserRecipe),
                            verified=True,
                            primary=True)
Пример #33
0
    other_income=MoneyInterval("per_week", pennies=2200),
)
savings = Recipe(Savings)
deductions = Recipe(
    Deductions,
    income_tax=MoneyInterval("per_week", pennies=2200),
    national_insurance=MoneyInterval("per_4week", pennies=2200),
    maintenance=MoneyInterval("per_year", pennies=2200),
    childcare=MoneyInterval("per_week", pennies=2200),
    mortgage=MoneyInterval("per_week", pennies=2200),
    rent=MoneyInterval("per_week", pennies=2200),
)

person = Recipe(Person)
full_person = Recipe(
    Person, income=foreign_key(income), savings=foreign_key(savings), deductions=foreign_key(deductions)
)

eligibility_check = Recipe(
    EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5,
    dependants_old=6,
    you=foreign_key(person),
    partner=foreign_key(person),
)

eligibility_check_yes = Recipe(
    EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5,
Пример #34
0
from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models


django_file_path = Path(settings.APP_DIR, 'grunt/tests/media/test-audio.wav')
assert django_file_path.exists()
django_file = File(open(django_file_path, 'rb'))

chain = Recipe(grunt_models.Chain,
    name = 'mommy_chain')

seed = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    audio = django_file)

recording = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    parent = foreign_key(seed),
    audio = django_file)

question = Recipe(ratings_models.Question,
    # Needs to be a valid recording
    choices = related('seed', 'seed'),
    answer = foreign_key(seed))

response = Recipe(ratings_models.Response,
    question = foreign_key(question),
    selection = foreign_key(seed))
Пример #35
0
 def test_not_accept_other_type(self):
     with self.assertRaises(TypeError) as c:
         foreign_key('something')
     exception = c.exception
     self.assertEqual(exception.message, 'Not a recipe')
Пример #36
0
belzonte = Recipe(
    Destino,
    titulo="Belo Horizonte"
)

rondonia = Recipe(
    Destino,
    titulo="Rondonia"
)

city_tour_bh = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=True,
    destaque=True,
    destino=foreign_key(belzonte),
    preco_por=100.40
)

city_tour_bh_despublicado = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=False,
    destaque=True,
)

city_tour_bh_sem_destaque = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=True,
    destaque=False,
Пример #37
0
from model_mommy.recipe import Recipe, foreign_key

from ..models import ReasonForContacting, ReasonForContactingCategory

reasonforcontacting = Recipe(ReasonForContacting, _fill_optional=["user_agent", "referrer"])
reasonforcontacting_category = Recipe(
    ReasonForContactingCategory, reason_for_contacting=foreign_key(reasonforcontacting)
)
Пример #38
0
connectwise_board = Recipe(
    ConnectWiseBoard,
    name=seq('Board #'),
)

member = Recipe(
    Member,
    identifier=seq('user'),
    first_name=lambda: names.get_first_name(),
    last_name=lambda: names.get_last_name(),
)

project = Recipe(
    Project,
    name=seq('Project #'),
    manager=foreign_key(member),
)

company = Recipe(
    Company,
    name=seq('Company #'),
    identifier=seq('company'),
)

ticket_priority = Recipe(
    TicketPriority,
    name=seq('Priority #'),
)

ticket = Recipe(
    Ticket,
Пример #39
0
from model_mommy.recipe import Recipe, foreign_key, seq

from project.account.mommy_recipes import domain
from .models import EmailDomain, EmailUser, EmailForward, EmailAlias, CatchAll

email_domain = Recipe(
    EmailDomain,
    domain=foreign_key(domain),
)

email_user = Recipe(
    EmailUser,
    domain=foreign_key(email_domain),
)

email_forward = Recipe(
    EmailForward,
    user=foreign_key(email_user),
)

email_alias = Recipe(
    EmailAlias,
    user=foreign_key(email_user),
)

catch_all = Recipe(
    CatchAll,
    domain=foreign_key(email_domain),
    user=foreign_key(email_user),
)
Пример #40
0
 def test_foreign_key_method_returns_a_recipe_foreign_key_object(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     obj = foreign_key(number_recipe)
     self.assertIsInstance(obj, RecipeForeignKey)
Пример #41
0
from django.conf import settings

from model_mommy.recipe import Recipe, foreign_key, seq
from model_mommy import mommy

from .models import Zone, AddressRecord, CanonicalNameRecord, MailExchangeRecord, \
    NameServerRecord, TextRecord, ServiceRecord

# Dynamically import the mommy_recipe for the DOMAIN_MODEL
# If `DNS_MANAGER_DOMAIN_MODEL = 'vg.accounts.Domains'` then
# this is equivalent to: `from vg.account.mommy_recipes import domain`

t = settings.DNS_MANAGER_DOMAIN_MODEL.rsplit('.', 1)[0]
module = __import__(t + '.mommy_recipes', fromlist=['domain'])
domain = getattr(module, 'domain')

zone = Recipe(Zone, domain=foreign_key(domain))

address_record = Recipe(AddressRecord, zone=foreign_key(zone), ip=mommy.generators.gen_ipv4(),)

cname_record = Recipe(CanonicalNameRecord, zone=foreign_key(zone))

mx_record = Recipe(MailExchangeRecord, zone=foreign_key(zone))

ns_record = Recipe(NameServerRecord, zone=foreign_key(zone))

text_record = Recipe(TextRecord, zone=foreign_key(zone), text='"%s"' % seq("test"))

service_record = Recipe(ServiceRecord, zone=foreign_key(zone))
Пример #42
0
    os.path.join(CUR_DIR, 'kenya_boundary.geojson'))


country_boundary_recipe = Recipe(
    WorldBorder,
    mpoly=_get_mpoly_from_geom(KENYA_BORDER[0].get_geoms()[0])
)


county_recipe = Recipe(
    County
)

county_boundary_recipe = Recipe(
    CountyBoundary,
    area=foreign_key(county_recipe),
    mpoly=_get_mpoly_from_geom(COUNTY_BORDER[0].get_geoms()[0])
)

constituency_recipe = Recipe(
    Constituency,
    county=foreign_key(county_recipe),
)

constituency_boundary_recipe = Recipe(
    ConstituencyBoundary,
    area=foreign_key(constituency_recipe),
    mpoly=_get_mpoly_from_geom(CONSTITUENCY_BORDER[0].get_geoms()[0])
)

Пример #43
0
from django.core.exceptions import ValidationError
from model_mommy import mommy
from model_mommy.recipe import Recipe, foreign_key
from django.core.urlresolvers import reverse

from fyt.test.testcases import TripsTestCase, WebTestCase
from fyt.db.models import TripsYear
from fyt.db.mommy_recipes import trips_year as trips_year_recipe
from fyt.raids.models import Raid, Comment

raid_recipe = Recipe(Raid, trips_year=foreign_key(trips_year_recipe))


class RaidModelsTestCase(TripsTestCase):

    def test_raid_requires_trip_or_campsite(self):
        with self.assertRaises(ValidationError):
            raid_recipe.prepare(campsite=None, trip=None).full_clean()


class RaidViewsTestCase(WebTestCase):

    def test_only_directors_can_delete_raids(self):
        trips_year = trips_year_recipe.make()
        raid = raid_recipe.make(trips_year=trips_year)
        url = raid.delete_url()
        self.app.get(url, user=self.mock_user(), status=403)  # No good
        resp = self.app.get(url, user=self.mock_director())  # OK
        resp.form.submit()
        with self.assertRaises(Raid.DoesNotExist):
            Raid.objects.get()
Пример #44
0
REPORTER_NAME = 'rep'

public_ci = Recipe(CriticalIncident,
    incident = seq('Critical Incident '),
    public = True
)

published_incident = Recipe(PublishableIncident,
    publish = True,
    critical_incident__public = True,
    critical_incident__department__label = seq('Dept_'),
    critical_incident__department__reporter__user__username = seq(REPORTER_NAME),
)

translated_pi = Recipe(PublishableIncidentTranslation, 
    incident = seq('Published Incident '),
    master = foreign_key(published_incident)
)

reviewer = Recipe(Reviewer,
    user__username = seq('rev'),
    user__email = seq('rev@localhost'),
)

reporter = Recipe(Reporter,
    user__username = seq(REPORTER_NAME))

department = Recipe(Department,
    label = seq('Dept_'),
    reporter__user__username = seq(REPORTER_NAME)
)
Пример #45
0
from django.contrib.auth.models import User

from kb.base import choices
from kb.models import Article, Category, Vote
from model_mommy.recipe import foreign_key, Recipe, related

person = Recipe(User)

draft_article = Recipe(Article,
                       title='Draft Article Title',
                       content='Draft Article Content',
                       publish_state=choices.PublishChoice.Draft,
                       created_by=foreign_key(person))

published_article = Recipe(Article,
                           title='Published Article Title',
                           content='Published Article Content',
                           publish_state=choices.PublishChoice.Published,
                           created_by=foreign_key(person))

category_without_articles = Recipe(Category,
                                   name='Category Without Articles Title',
                                   description='Category Without Articles Description')

category_with_articles = Recipe(Category,
                                name='Category With Articles Title',
                                description='Category With Articles Description',
                                articles=related('draft_article',
                                                 'published_article'))

vote = Recipe(Vote, article__content='Markdown')
Пример #46
0
    name = 'San Francisco',
    slug = 'san-francisco',
    description = 'San Francisco',
    timezone = '-8.0',
    city = 'San Francisco',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    private = True
    )

location_mars = Recipe(
    Location,
    name = 'Mars',
    slug = 'mars',
    description = 'Mars',
    timezone = '-8.0',
    city = 'Mars',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    capacity = '100'
    )

registration = Recipe(
    Registration,
    location = foreign_key(location),
    # user = foreign_key(user),
    )
Пример #47
0
 def test_not_accept_other_type(self):
     with pytest.raises(TypeError) as c:
         foreign_key(2)
     exception = c.value
     assert str(exception) == 'Not a recipe'
Пример #48
0
from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models
import transcribe.models as transcribe_models


django_file_path = Path(settings.APP_DIR, 'grunt/tests/media/test-audio.wav')
assert django_file_path.exists()
django_file = File(open(django_file_path, 'rb'))

chain = Recipe(grunt_models.Chain,
    name = 'mommy_chain')

seed = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    audio = django_file)

recording = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    parent = foreign_key(seed),
    audio = django_file)

transcription_survey = Recipe(transcribe_models.TranscriptionSurvey)
message_to_transcribe = Recipe(transcribe_models.MessageToTranscribe,
    survey = foreign_key(transcription_survey),
    given = foreign_key(recording),
)
transcription = Recipe(transcribe_models.Transcription,
    message = foreign_key(message_to_transcribe))
Пример #49
0
from model_mommy.recipe import Recipe, foreign_key, seq

from project.account.mommy_recipes import domain
from .models import EmailDomain, EmailUser, EmailForward, EmailAlias, CatchAll

email_domain = Recipe(EmailDomain,
                      domain=foreign_key(domain),
                      )

email_user = Recipe(EmailUser,
                    domain=foreign_key(email_domain),
                    )

email_forward = Recipe(EmailForward,
                       user=foreign_key(email_user),
                       )

email_alias = Recipe(EmailAlias,
                     user=foreign_key(email_user),
                     )

catch_all = Recipe(CatchAll,
                   domain=foreign_key(email_domain),
                   user=foreign_key(email_user),
                   )
Пример #50
0
serial_numbers_by = Recipe(DummyDefaultFieldsModel,
    default_decimal_field = seq(Decimal('20.1'), increment_by=Decimal('2.4')),
    default_int_field = seq(10, increment_by=3),
    default_float_field = seq(1.23, increment_by=1.8)
)

serial_datetime = Recipe(DummyDefaultFieldsModel,
    default_date_field = seq(TEST_TIME.date(), timedelta(days=1)),
    default_date_time_field = seq(TEST_TIME, timedelta(hours=3)),
    default_time_field = seq(TEST_TIME.time(), timedelta(seconds=15))
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)

other_dog = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key('person')
)

other_dog_unicode = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key(u('person'))
)

dummy_unique_field = Recipe(DummyUniqueIntegerFieldModel,
    value = seq(10),
)
Пример #51
0
person = Recipe(Person,
                name='John Doe',
                nickname='joe',
                age=18,
                bio='Someone in the crowd',
                blog='http://joe.blogspot.com',
                wanted_games_qtd=4,
                birthday=now().date(),
                appointment=now(),
                birth_time=now())

serial_person = Recipe(
    Person,
    name=seq('joe'),
)

serial_numbers = Recipe(DummyDefaultFieldsModel,
                        default_decimal_field=seq(Decimal('20.1')),
                        default_int_field=seq(10),
                        default_float_field=seq(1.23))

dog = Recipe(Dog, breed='Pug', owner=foreign_key(person))

other_dog = Recipe(Dog, breed='Basset', owner=foreign_key('person'))

dummy_unique_field = Recipe(
    DummyUniqueIntegerFieldModel,
    value=seq(10),
)
Пример #52
0
an **object-oriented** computer programming language commonly used to
create interactive effects within *web browsers*.''',
    ''''# Python

a *high-level* **general-purpose** _programming language_.''',
]

user = Recipe(
    User,
    email="*****@*****.**",
    is_active=True
)

category = Recipe(
    Category,
    title=seq('Category'),
    author=foreign_key(user),
    description=cycle('description'),
    _quantity=3
)

article = Recipe(
    Article,
    title=seq('Article'),
    author=foreign_key(user),
    category=foreign_key(category),
    content=cycle(definitions),
    _quantity=5
)
Пример #53
0
doctor_recipe = Recipe(
    Doctor,
    doctor_code=seq(10001000, 15),
    education=cycle([type[0] for type in EDUCATION_TYPES]),
    speciality=cycle([type[0] for type in SPECIALITY_TYPES]),
    insurance=cycle([type[0] for type in INSURANCE_TYPES]),
    contract='contracts/',
    price=seq(30000, 2000),
)

patient_recipe = Recipe(Patient, )

system_user_recipe = Recipe(SystemUser,
                            id_code=seq('333222111'),
                            role=foreign_key(patient_recipe))

reservation_recipe = Recipe(
    Reservation,
    doctor=foreign_key(doctor_recipe),
    patient=foreign_key(system_user_recipe),
    rejected=False,
    from_time=cycle([type[0] for type in HOURS][8:14]),
    to_time=cycle([type[0] for type in HOURS][15:22]),
)


def create_multiple_doctors(quantity):
    offices = office_recipe.make(_quantity=quantity)
    doctors = doctor_recipe.make(_quantity=quantity, office=cycle(offices))
    system_users = system_user_recipe.make(_quantity=quantity,
Пример #54
0
 def test_not_accept_other_type(self):
     with self.assertRaises(TypeError) as c:
         foreign_key(2)
     exception = c.exception
     self.assertEqual(str(exception), 'Not a recipe')
Пример #55
0
user = Recipe(User,
              username=seq("test_user"),
              password="******",
              email="*****@*****.**",
              )

# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_YC = Recipe(EventType, event_type="CL", subtype=seq("Yoga class"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))

future_EV = Recipe(Event,
                      date=future,
                      event_type=foreign_key(event_type_YC))

future_WS = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_WS))

# past event
past_event = Recipe(Event,
                    date=past,
                    event_type=foreign_key(event_type_WS),
                    advance_payment_required=True,
                    cost=10,
                    payment_due_date=past-timedelta(10)
                    )

block = Recipe(Block)
Пример #56
0
from model_mommy.recipe import Recipe, seq, foreign_key
from ..models import Provider, ProviderAllocation, OutOfHoursRota, Staff, \
    Feedback, CSVUpload


provider = Recipe(Provider,
    name=seq('Name'),
)

staff = Recipe(Staff)

outofhoursrota = Recipe(OutOfHoursRota)

provider_allocation = Recipe(ProviderAllocation)

feedback = Recipe(Feedback, created_by=foreign_key(staff))

csvupload_determination = Recipe(CSVUpload,
                   body=[
                       u'2222222', u'0000', u'1A111A', u'A', u'Corgi',
                       u'01/01/1901', u'D', u'F', u'1', u'', u'', u'SW1A 1AA',
                       u'', u'SWAG', u'YOLO', u'', u'', u'', u'', u'', u'18',
                       u'99.5', u'', u'MOB', u'', u'', u'AAAA', u'', u'', u'',
                       u'NAR', u'', u'', u'TA'
                   ]
)


csvupload_case = \
    Recipe(CSVUpload,
           body=[
Пример #57
0
from cirs.models import Department

REPORTER_NAME = 'rep'

public_ci = Recipe(CriticalIncident,
                   incident=seq('Critical Incident '),
                   public=True)

published_incident = Recipe(
    PublishableIncident,
    publish=True,
    critical_incident__public=True,
    critical_incident__department__label=seq('Dept_'),
    critical_incident__department__reporter__user__username=seq(REPORTER_NAME),
)

translated_pi = Recipe(PublishableIncidentTranslation,
                       incident=seq('Published Incident '),
                       master=foreign_key(published_incident))

reviewer = Recipe(
    Reviewer,
    user__username=seq('rev'),
    user__email=seq('rev@localhost'),
)

reporter = Recipe(Reporter, user__username=seq(REPORTER_NAME))

department = Recipe(Department,
                    label=seq('Dept_'),
                    reporter__user__username=seq(REPORTER_NAME))
Пример #58
0
# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_PC = Recipe(EventType,
                       event_type="CL",
                       subtype=seq("Pole level class"))
event_type_PP = Recipe(EventType,
                       event_type="CL",
                       subtype=seq("Pole practice"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))
event_type_OE = Recipe(EventType, event_type="EV", subtype=seq("Other event"))
event_type_OC = Recipe(EventType, event_type="CL", subtype=seq("Other class"))
event_type_RH = Recipe(EventType, event_type="RH", subtype=seq("Room hire"))

future_EV = Recipe(Event, date=future, event_type=foreign_key(event_type_OE))

future_WS = Recipe(Event, date=future, event_type=foreign_key(event_type_WS))

future_PC = Recipe(Event, date=future, event_type=foreign_key(event_type_PC))
future_PP = Recipe(Event, date=future, event_type=foreign_key(event_type_PP))
future_CL = Recipe(Event, date=future, event_type=foreign_key(event_type_OC))
future_RH = Recipe(Event, date=future, event_type=foreign_key(event_type_RH))

# past event
past_event = Recipe(Event,
                    date=past,
                    event_type=foreign_key(event_type_WS),
                    advance_payment_required=True,
                    cost=10,
                    payment_due_date=past - timedelta(10))
Пример #59
0
    pension=MoneyInterval('per_month', pennies=0),
    other_income=MoneyInterval('per_week', pennies=2200)
)
savings = Recipe(Savings)
deductions = Recipe(Deductions,
                    income_tax = MoneyInterval('per_week', pennies=2200),
                    national_insurance = MoneyInterval('per_4week', pennies=2200),
                    maintenance = MoneyInterval('per_year', pennies=2200),
                    childcare = MoneyInterval('per_week', pennies=2200),
                    mortgage = MoneyInterval('per_week', pennies=2200),
                    rent = MoneyInterval('per_week', pennies=2200)
                    )

person = Recipe(Person)
full_person = Recipe(Person,
    income=foreign_key(income),
    savings=foreign_key(savings),
    deductions=foreign_key(deductions)
)

eligibility_check = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),
    partner=foreign_key(person)
)

eligibility_check_yes = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),