예제 #1
0
from meta_ae.models.ae_followup import AeFollowup
from meta_ae.models.ae_initial import AeInitial
from meta_ae.models.ae_susar import AeSusar
from meta_ae.models.ae_tmg import AeTmg
from meta_ae.models.death_report import DeathReport

aeinitial = Recipe(
    AeInitial,
    action_identifier=None,
    tracking_identifier=None,
    ae_description="A description of this event",
    ae_grade=GRADE4,
    ae_study_relation_possibility=YES,
    ae_start_date=get_utcnow().date(),
    ae_awareness_date=get_utcnow().date(),
    study_drug_relation="not_related",
    ae_treatment="Some special treatment",
    sae=NO,
    susar=NO,
    susar_reported=NOT_APPLICABLE,
    ae_cause=NO,
    ae_cause_other=None,
)

aetmg = Recipe(AeTmg, action_identifier=None, tracking_identifier=None)

aesusar = Recipe(AeSusar, action_identifier=None, tracking_identifier=None)

aefollowup = Recipe(AeFollowup,
                    relevant_history=NO,
예제 #2
0
from faker import Faker
from model_bakery.recipe import Recipe

from .models import Route

fake = Faker()

route = Recipe(
    Route,
    origin=fake.address(),
    destination=fake.address(),
    frequency=[
        fake.pyint(min_value=1, max_value=7, step=1),
        fake.pyint(min_value=1, max_value=7, step=1),
        fake.pyint(min_value=1, max_value=7, step=1),
    ],
    length=fake.pyint(min_value=100, max_value=50000, step=1),
    waypoints=[fake.address(), fake.address(),
               fake.address()],
)
예제 #3
0
    DummyNumbersModel,
    Person,
)

recipe_attrs = {
    "name": "John Doe",
    "nickname": "joe",
    "age": 18,
    "bio": "Someone in the crowd",
    "birthday": now().date(),
    "appointment": now(),
    "blog": "https://joe.example.com",
    "days_since_last_login": 4,
    "birth_time": now(),
}
person_recipe = Recipe(Person, **recipe_attrs)


def test_import_seq_from_recipe():
    """Import seq method directly from recipe module."""
    try:
        from model_bakery.recipe import seq  # NoQA
    except ImportError:
        pytest.fail("{} raised".format(ImportError.__name__))


@pytest.mark.django_db
class TestDefiningRecipes:
    def test_flat_model_make_recipe_with_the_correct_attributes(self):
        """Test a 'flat model' - without associations, like FK, M2M and O2O."""
        person = person_recipe.make()
예제 #4
0
from model_bakery.recipe import Recipe

from .models import DeliveryOption

central_logistic = Recipe(
    DeliveryOption, name="traidoo", id=DeliveryOption.CENTRAL_LOGISTICS
)
seller = Recipe(DeliveryOption, name="seller", id=DeliveryOption.SELLER)
buyer = Recipe(DeliveryOption, name="buyer", id=DeliveryOption.BUYER)
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "helloworld.settings")

import django
django.setup()

from faker import factory, Faker
from sample_app.models import *
from model_bakery.recipe import Recipe, foreign_key

fake = Faker()

for k in range(100):
    author = Recipe(
        Author,
        name=fake.name(),
        createdDate=fake.future_datetime(end_date="+30d", tzinfo=None),
        updatedDate=fake.future_datetime(end_date="+30d", tzinfo=None),
    )

    question = Recipe(
        Question,
        question_text=fake.sentence(nb_words=6, variable_nb_words=True),
        pub_date=fake.future_datetime(end_date="+30d", tzinfo=None),
        refAuthor=foreign_key(author),
        createdDate=fake.future_datetime(end_date="+30d", tzinfo=None),
        updatedDate=fake.future_datetime(end_date="+30d", tzinfo=None),
    )

    choice = Recipe(
        Choice,
        question=foreign_key(question),
예제 #6
0
from django.contrib.sites.models import Site
from edc_utils import get_utcnow
from model_bakery.recipe import Recipe

from inte_prn.models import IntegratedCareClinicRegistration

integratedcareclinicregistration = Recipe(
    IntegratedCareClinicRegistration,
    site=Site.objects.get_current(),
    report_datetime=get_utcnow(),
    date_opened=get_utcnow(),
)
예제 #7
0
from model_bakery.recipe import Recipe

from categories.models import Category, CategoryIcon

category_icon = Recipe(CategoryIcon)
category = Recipe(Category)
예제 #8
0
from model_bakery.recipe import Recipe, foreign_key

from accounts.baker_recipes import user
from apikey import models
from multi_tenant.baker_recipes import client

apikey = Recipe(
    models.ApiKey,
    subscriber=foreign_key(client),
    created_by=foreign_key(user),
    deactivated_by=None,
    _fill_optional=True,
)
예제 #9
0
from datetime import datetime, timezone

from model_bakery.recipe import Recipe, foreign_key

from common.enums import NotificationWebhookTypes, StateFieldFormats
from election import models

new_state = Recipe(models.State, code="XX")
state = Recipe(
    models.State,
    created_at=datetime.now(timezone.utc),
)

markdown_field_type = Recipe(
    models.StateInformationFieldType,
    slug="example_markdown_field",
    long_name="An Example Markdown Field",
    field_format=StateFieldFormats.MARKDOWN,
)

markdown_information = Recipe(
    models.StateInformation,
    field_type=foreign_key(markdown_field_type),
    state=foreign_key(new_state),
    text="# Great Information",
    notes="Just a headline",
)

netlify_webhook = Recipe(
    models.UpdateNotificationWebhook,
    type=NotificationWebhookTypes.NETLIFY,
예제 #10
0
from makeReports.models.data_models import AssessmentAggregate, AssessmentData, ResultCommunicate
from .basic_recipes import report
from .assessment_recipes import assessmentVersion

semesterDates = [
    'Fall 2015-Spring 2020', "Fall 2019", "Summer 2018",
    "Spring 2017-Fall 2018", "Spring 2018, Fall 2019, Spring 2020",
    "Summer 2017 to Spring 2018", "Summer 2021 to Fall 2022",
    "Fall and Spring 2017"
]
percentages = [20, 17, 95, 87, 92, 84, 78, 91]
students = [2, 20, 542, 212, 123, 75, 31, 10, 12, 44]

assessmentData = Recipe(AssessmentData,
                        assessmentVersion=foreign_key(assessmentVersion),
                        dataRange=cycle(semesterDates),
                        overallProficient=cycle(percentages),
                        numberStudents=cycle(students))

assessmentAggregate = Recipe(AssessmentAggregate,
                             assessmentVersion=foreign_key(assessmentVersion),
                             aggregate_proficiency=cycle(percentages))

rCs = [
    "We publish all data on the website. We send out emails to inform the department when new results are posted.",
    "A weekly meeting is held. When appropriate, new results are shared during this meeting by the assessment head. Later, they are sent via email.",
    "As a new department, practices are still being put into place. Usually the head of the department sends updated Excel reports to faculty.",
    "The information is listed on paper available in the office."
]

resultCommunicate = Recipe(ResultCommunicate,
예제 #11
0
from .models import Agent
from model_bakery.recipe import Recipe, seq
from itertools import cycle
from django.utils import timezone as djangotime

agent = Recipe(
    Agent,
    client="Default",
    site="Default",
    hostname=seq("TestHostname"),
    monitoring_type=cycle(["workstation", "server"]),
)

server_agent = agent.extend(
    monitoring_type="server",
)

workstation_agent = agent.extend(
    monitoring_type="workstation",
)

online_agent = agent.extend(last_seen=djangotime.now())

overdue_agent = agent.extend(
    last_seen=djangotime.now() - djangotime.timedelta(minutes=6)
)

agent_with_services = agent.extend(
    services=[
        {
            "pid": 880,
예제 #12
0
from .tests.models import SubjectConsent

fake = Faker()

subjectconsent = Recipe(
    SubjectConsent,
    consent_datetime=get_utcnow,
    dob=get_utcnow() - relativedelta(years=25),
    first_name=fake.first_name,
    last_name=fake.last_name,
    # note, passes for model but won't pass validation in modelform clean()
    initials="AA",
    gender=MALE,
    # will raise IntegrityError if multiple made without _quantity
    identity=seq("12315678"),
    # will raise IntegrityError if multiple made without _quantity
    confirm_identity=seq("12315678"),
    identity_type="passport",
    is_dob_estimated="-",
    language="en",
    is_literate=YES,
    is_incarcerated=NO,
    study_questions=YES,
    consent_reviewed=YES,
    consent_copy=YES,
    assessment_score=YES,
    consent_signature=YES,
    site=Site.objects.get_current(),
)
예제 #13
0
from .models import Script
from model_bakery.recipe import Recipe

script = Recipe(
    Script,
    name="Test Script",
    description="Test Desc",
    shell="cmd",
    script_type="userdefined",
)
예제 #14
0
from faker import Faker
from model_bakery.recipe import Recipe

from .models import DeliveryAddress

fake = Faker()

delivery_address = Recipe(
    DeliveryAddress,
    company_name=fake.company(),
    street=fake.street_address(),
    zip=fake.zipcode(),
    city=fake.city(),
)
예제 #15
0
from edc_constants.constants import YES, NO, MOBILE_NUMBER
from edc_utils import get_utcnow
from edc_visit_tracking.constants import SCHEDULED
from faker import Faker
from model_bakery.recipe import Recipe, seq

from .models import SubjectReconsent
from .models import SubjectConsent
from .models import SubjectRequisition
from .models import SubjectVisit


fake = Faker()


subjectvisit = Recipe(SubjectVisit, reason=SCHEDULED)

subjectrequisition = Recipe(SubjectRequisition)

subjectconsent = Recipe(
    SubjectConsent,
    assessment_score=YES,
    confirm_identity=seq("12315678"),
    consent_copy=YES,
    consent_datetime=get_utcnow(),
    consent_reviewed=YES,
    consent_signature=YES,
    dob=get_utcnow() - relativedelta(years=25),
    first_name=fake.first_name,
    gender="M",
    identity=seq("12315678"),
예제 #16
0
from faker import Faker
from model_bakery.recipe import Recipe, foreign_key

from products.baker_recipes import product
from users.baker_recipes import user
from .models import Cart, CartItem


fake = Faker()


cart = Recipe(Cart, user=foreign_key(user))


cartitem = Recipe(
    CartItem,
    product=foreign_key(product),
    cart=foreign_key(cart),
    quantity=fake.pyint(min_value=0, max_value=20)
)
예제 #17
0
from model_bakery import seq
from model_bakery.recipe import Recipe, foreign_key, related
from service.helper.enums import OGCServiceEnum, OGCServiceVersionEnum, MetadataEnum, DocumentEnum, OGCOperationEnum
from service.models import Metadata, Service, ServiceType, Layer, FeatureType, Keyword, Category, \
    Document, RequestOperation, MimeType, ProxyLog, Dataset, AllowedOperation, OGCOperation
from tests.baker_recipes.structure_app.baker_recipes import superadmin_group, superadmin_orga
from django.utils import timezone

mimetype = Recipe(MimeType, mime_type="image/png")

active_wms_service_metadata = Recipe(
    Metadata,
    title=seq("metadata_wms_"),
    identifier=seq("metadata_wms"),
    is_active=True,
    metadata_type=MetadataEnum.SERVICE.value,
    created_by=foreign_key(superadmin_group),
    formats=related(mimetype),
)

active_wms_layer_metadata = active_wms_service_metadata.extend(
    metadata_type=MetadataEnum.LAYER.value,
    identifier=seq("metadata_wms_layer"),
    formats=related(mimetype),
)

active_wfs_service_metadata = Recipe(
    Metadata,
    title=seq("metadata_wfs_"),
    identifier=seq("metadata_wfs"),
    is_active=True,
예제 #18
0
from django.utils.timezone import now

from model_bakery.recipe import Recipe
from tests.generic.models import Person

person = Recipe(
    Person,
    name="Uninstalled",
    nickname="uninstalled",
    age=18,
    bio="Uninstalled",
    blog="http://uninstalled.com",
    days_since_last_login=4,
    birthday=now().date(),
    appointment=now(),
    birth_time=now(),
)
예제 #19
0
from datetime import timedelta

from django.utils import timezone

from model_bakery.recipe import Recipe

from booking.models import Event, Block

now = timezone.now()
past = now - timedelta(30)
future = now + timedelta(30)


future_event = Recipe(Event, start=future, show_on_site=True)
past_event = Recipe(Event, start=past, show_on_site=True)

dropin_block = Recipe(Block)
course_block = Recipe(Block, block_config__course=True)
예제 #20
0
from model_bakery.timezone import now
from tests.generic.models import (
    TEST_TIME,
    Dog,
    DummyDefaultFieldsModel,
    DummyUniqueIntegerFieldModel,
    Person,
    School,
)

person = Recipe(
    Person,
    name="John Doe",
    nickname="joe",
    age=18,
    bio="Someone in the crowd",
    blog="http://joe.blogspot.com",
    days_since_last_login=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),
예제 #21
0
    CityCouncilAttendanceList,
    CityCouncilBid,
    CityCouncilContract,
    CityCouncilExpense,
    CityCouncilMinute,
    CityCouncilRevenue,
    CityHallBid,
    Gazette,
    GazetteEvent,
)
from model_bakery.recipe import Recipe, foreign_key

CityCouncilAgenda = Recipe(
    CityCouncilAgenda,
    date=date(2020, 3, 18),
    details="PROJETOS DE LEI ORDINÁRIA EM 2ª DISCUSSÃO 017/20",
    event_type="sessao_ordinaria",
    title="ORDEM DO DIA - 18 DE MARÇO DE 2020",
)


CityCouncilAttendanceList = Recipe(
    CityCouncilAttendanceList,
    date=date(2020, 2, 3),
    description="Abertura da 1ª etapa do 4º período da 18ª legislatura",
    council_member="Competente da Silva",
    status="presente",
)


CityCouncilBid = Recipe(CityCouncilBid)
예제 #22
0
 def test_accepts_generators(self):
     r = Recipe(DummyBlankFieldsModel,
                blank_char_field=itertools.cycle(["a", "b"]))
     assert "a" == r.make().blank_char_field
     assert "b" == r.make().blank_char_field
     assert "a" == r.make().blank_char_field
예제 #23
0
from model_bakery.recipe import Recipe, foreign_key
from main.models import Product, Item, Order

tc_01_product = Recipe(Product, _fill_optional=True)
tc_01_item = Recipe(Item,
                    _product=foreign_key('tc_01_product'),
                    qty=2,
                    price=10000)
tc_01_expected_result = 20000

tc_02_order = Recipe(Order, _fill_optional=True)
예제 #24
0
 def test_accepts_iterators(self):
     r = Recipe(DummyBlankFieldsModel,
                blank_char_field=iter(["a", "b", "c"]))
     assert "a" == r.make().blank_char_field
     assert "b" == r.make().blank_char_field
     assert "c" == r.make().blank_char_field
예제 #25
0
from model_bakery import baker
from model_bakery.recipe import Recipe

from .models import CustomUser

user_recipe = Recipe(
    CustomUser,
    password='******',
    is_active=True,
    is_staff=False,
    is_superuser=False,
)
예제 #26
0
 def test_empty_iterator_exception(self):
     r = Recipe(DummyBlankFieldsModel, blank_char_field=iter(["a", "b"]))
     assert "a" == r.make().blank_char_field
     assert "b" == r.make().blank_char_field
     with pytest.raises(RecipeIteratorEmpty):
         r.make()
예제 #27
0
from model_bakery.recipe import Recipe
from tests.generic.models import Person

from datetime import date, datetime

person = Recipe(
    Person,
    name="John Deeper",
    nickname="joe",
    age=18,
    bio="Someone in the crowd",
    blog="http://joe.blogspot.com",
    days_since_last_login=4,
    birthday=date.today(),
    appointment=datetime.now(),
    birth_time=datetime.now,
)
예제 #28
0
 def test_accepts_callable(self):
     r = Recipe(DummyBlankFieldsModel,
                blank_char_field=lambda: "callable!!")
     value = r.make().blank_char_field
     assert value == "callable!!"
예제 #29
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)
     assert isinstance(obj, RecipeForeignKey)
예제 #30
0
from django.contrib.auth import get_user_model
from model_bakery.recipe import Recipe

User = get_user_model()
user = Recipe(
    User,
    username="******",
    password=
    "******",
    email="*****@*****.**",
)