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() assert dog.id is None assert dog.owner.id is None
from model_bakery.recipe import Recipe, foreign_key from election.models import State from .models import Address, Office, Region region = Recipe(Region) office = Recipe(Office, region=foreign_key(region)) address = Recipe(Address, phone="+16175551234", fax="+16175555678", office=foreign_key(office)) absentee_ballot_address = Recipe( Address, phone="+16175551234", fax="+16175555678", office=foreign_key(office), process_absentee_requests=True, is_regular_mail=True, email="*****@*****.**", address="Right Office", address2="123 Main Street", address3="Ste. 123", city="FOO CITY", state=foreign_key(Recipe(State, code="AA")), zipcode="12345", ) ABSENTEE_BALLOT_MAILING_ADDRESS = ( "Right Office\n123 Main Street\nSte. 123\nFoo City, AA 12345")
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)
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), start="xpto"), ) 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), ) dog_with_more_friends = dog.extend(friends_with=related(dog_with_friends), ) extended_dog = dog.extend(breed="Super basset", )
samples = [ "The students who do not choose the original research option", "The students who chose to take the class", "All students who turned the survey in", "All mentors who were present on the last day of the semester", "The students who did not receive an A in CEEN 4020" ] frequency = [ "During the Fall and Spring, but no during the summer", "During the summer only", "During the spring semester only" ] thresholds = [ "Students score competence in all sections of rubric", "Students receive a pass from 4 out of 5 board members", "All survey items were rated at least adequate", "The student received high marks on the evaluation", "The student mastered a majority of the content" ] assessmentVersion = Recipe(AssessmentVersion, report=foreign_key(report), slo=foreign_key(sloInReport), assessment=foreign_key(assessment), description=cycle(descriptions), where=cycle(wheres), sampleDescription=cycle(samples), frequency=cycle(frequency), threshold=cycle(thresholds))
def test_fail_load_invalid_recipe(self): with pytest.raises(AttributeError): foreign_key("tests.generic.nonexisting_recipe")
from faker import Faker from model_bakery.recipe import Recipe, foreign_key from products.baker_recipes import product from .models import Item fake = Faker() item = Recipe( Item, product=foreign_key(product), quantity=10, latest_delivery_date=fake.future_date(end_date="+2d", tzinfo=None), )
# institutions institution = Recipe("hipeac.Institution") # projects project = Recipe("hipeac.Project", start_date=now.date, end_date=now.add(years=2).date) # events event = Recipe( "hipeac.Event", coordinating_institution=foreign_key(institution), registration_start_date=now.date, registration_early_deadline=now.add(days=30).datetime, registration_deadline=now.add(days=60).datetime, start_date=now.add(days=60).date, end_date=now.add(days=65).date, ) roadshow = Recipe("hipeac.Roadshow", start_date=now.add(days=30).date, end_date=now.add(days=35).date) session_type = Recipe("hipeac.Metadata", type=Metadata.SESSION_TYPE) session = Recipe( "hipeac.Session", session_type=foreign_key(session_type), date=now.add(days=62).date, event=foreign_key(event) ) # users
recurrencesymptom = Recipe(RecurrenceSymptom, action_identifier=None, tracking_identifier=None) meningitissymptom = Recipe(MeningitisSymptom, name=OTHER, display_name="Other") neurological = Recipe(Neurological, name="meningismus", display_name="Meningismus") deathreport = Recipe( DeathReport, study_day=1, death_as_inpatient=YES, cause_of_death=foreign_key(causeofdeath), cause_of_death_other=None, action_identifier=None, tracking_identifier=None, ) deathreporttmg = Recipe( DeathReportTmg, action_identifier=None, cause_of_death=foreign_key(causeofdeath), cause_of_death_agreed=YES, tracking_identifier=None, ) deathreporttmgsecond = Recipe( DeathReportTmgSecond,
sponsorship__sponsor__name="Awaiting Sponsor", sponsorship__start_date=today, benefits_list="- benefit 1", legal_clauses="", status=Contract.AWAITING_SIGNATURE, ) package = Recipe(SponsorshipPackage) finalized_sponsorship = Recipe( Sponsorship, sponsor__name="Sponsor Name", status=Sponsorship.FINALIZED, start_date=today - two_days, end_date=today + two_days, package=foreign_key(package), ) logo_at_download_feature = Recipe( LogoPlacement, publisher=PublisherChoices.FOUNDATION.value, logo_place=LogoPlacementChoices.DOWNLOAD_PAGE.value, ) logo_at_sponsors_feature = Recipe( LogoPlacement, publisher=PublisherChoices.FOUNDATION.value, logo_place=LogoPlacementChoices.SPONSORS_PAGE.value, ) logo_at_pypi_feature = Recipe(
] MCs = [ "Some SLOS include more than a single independent construct.", "SLOs are gnerally observable but clarity is needed.", "Some SLOS are measured by direct evidence of student knowledge of skill and other by indirect means", "Some measures provide data that reflect the constructs", "Results are sporadically communicated to program faculty" ] MEs = [ "Specific examples of data-informed decisions are provided", "Specific porgram-imporvement actions have been initiated", "Data analysis is routine. Plans for systems is optimized.", "All measure provide data that reflect the constructs in the SLOs", "SLOs are presented in the context of the discipline.", "Alls SLOs are observable and sufficient to allow for observation and judgements." ] abbrevs = ["MO","NS","SA","STA","LS","PR","TQ"] rubricItem = Recipe(RubricItem, text = cycle(rIs), abbreviation = cycle(abbrevs), DMEtext = cycle(DNMs), MEtext = cycle(MCs), EEtext = cycle(MEs) ) gradedRubricItem = Recipe(GradedRubricItem, item = foreign_key(rubricItem) )
"Business Administration", "History", "Secondary Education", "Elementary Education", "Biology", "Physical Education" ] dp_names = [ "English", "Electrical Engineering", "Mathematics", "Statistics", "Computer Science", "IT Innovations", "Civil Engineering", "Secondary Education", "Business", 'Biology', "Ancient History", "Black Studies", "Physics" ] startingYear = [2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2035, 2037] cyclelength = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10] announcements = [ 'All reports must be completed by the end of this week.', "The system will be down for maitenance starting next week. Please plan accordingly.", "Our newest committee member is Sandra Lee. Please make sure to welcome her and ask any questions if needed via email.", "Reports will be assigned next week." ] college = Recipe(College, name=cycle(college_names)) department = Recipe(Department, name=cycle(department_names), college=foreign_key(college)) degreeProgram = Recipe(DegreeProgram, name=cycle(dp_names), department=foreign_key(department), startingYear=cycle(startingYear), cycle=cycle(cyclelength)) announcement = Recipe(Announcement, text=cycle(announcements))
from faker import Faker from model_bakery.recipe import Recipe, foreign_key from users.baker_recipes import staff_user fake = Faker() setting = Recipe( "settings.Setting", central_logistics_company=True, platform_user=foreign_key(staff_user), deposit_vat=19, mc_swiss_delivery_fee_vat=19, ) global_setting = Recipe("settings.GlobalSetting", product_vat=[0, 7, 11, 19])
# coding: utf-8 from django.utils import timezone from faker import Faker from model_bakery.recipe import Recipe, foreign_key from .models import Sale fake = Faker("pt_BR") sale = Recipe(Sale, code=fake.ean, value=700, date=timezone.localtime, reseller=foreign_key("users.user"), status=Sale.IN_VALIDATION, percentage=10, cashback=70)
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(), ) lonely_person = Recipe(LonelyPerson, only_friend=foreign_key(person, one_to_one=True)) 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), ) serial_numbers_by = Recipe( DummyDefaultFieldsModel,
from model_bakery.recipe import Recipe, foreign_key from multi_tenant import models client = Recipe(models.Client, name="My Great Organization", url="http://vote.local") subscriberslug = Recipe(models.SubscriberSlug, slug="greatorg", subscriber=foreign_key(client))
) 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", ) CityCouncilContract = Recipe(CityCouncilContract) CityCouncilExpense = Recipe(CityCouncilExpense) CityCouncilMinute = Recipe(CityCouncilMinute) Gazette = Recipe(Gazette, ) GazetteEvent = Recipe(GazetteEvent, gazette=foreign_key(Gazette)) CityHallBid = Recipe(CityHallBid)
from model_bakery.recipe import Recipe, foreign_key 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." ]
return f"{rand}-{hostname}" site = Recipe("clients.Site") def get_wmi_data(): with open( os.path.join(settings.BASE_DIR, "tacticalrmm/test_data/wmi_python_agent.json") ) as f: return json.load(f) agent = Recipe( "agents.Agent", site=foreign_key(site), hostname="DESKTOP-TEST123", version="1.3.0", monitoring_type=cycle(["workstation", "server"]), agent_id=seq("asdkj3h4234-1234hg3h4g34-234jjh34|DESKTOP-TEST123"), ) server_agent = agent.extend( monitoring_type="server", ) workstation_agent = agent.extend( monitoring_type="workstation", ) online_agent = agent.extend(last_seen=djangotime.now())
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, )
def test_load_from_other_module_recipe(self): dog = Recipe(Dog, owner=foreign_key("tests.generic.person")).make() assert dog.owner.name == "John Doe"
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, name="Test Trigger Endpoint", trigger_url="http://test.local/trigger_endpoint", active=True, )
from model_bakery.recipe import Recipe, foreign_key from action.baker_recipes import action from .models import Registration registration = Recipe(Registration, action=foreign_key(action))
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) )
from model_bakery.recipe import Recipe, foreign_key from multi_tenant import models client = Recipe(models.Client, name="My Great Organization", url="http://vote.local") partnerslug = Recipe(models.PartnerSlug, slug="greatorg", partner=foreign_key(client))
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, metadata_type=MetadataEnum.SERVICE.value,
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)
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), choice_text=fake.sentence(nb_words=1, variable_nb_words=True), createdDate=fake.future_datetime(end_date="+30d", tzinfo=None), updatedDate=fake.future_datetime(end_date="+30d", tzinfo=None), ) choice.make()
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"
god_user = Recipe( MrMapUser, username="******", email="*****@*****.**", salt=salt, password=make_password("354Dez25!"), is_active=True, ) superadmin_orga = Recipe(Organization, organization_name=seq("SuperOrganization"), is_auto_generated=False) superadmin_group = Recipe(MrMapGroup, name=SUPERUSER_GROUP_NAME, created_by=foreign_key(god_user), organization=foreign_key(superadmin_orga)) public_group = Recipe( MrMapGroup, name=PUBLIC_GROUP_NAME, description="Public", is_public_group=True, created_by=foreign_key(god_user), ) superadmin_user = Recipe(MrMapUser, username="******", email="*****@*****.**", salt=salt, password=make_password(PASSWORD, salt=salt),