def campaign_type_get_or_create(**kwargs): def get_campaign_type(): try: campaign_type = CampaignType.objects.get(**kwargs) except CampaignType.DoesNotExist: campaign_type = CampaignTypeRecipe.make(**kwargs) return campaign_type return get_campaign_type campaign_type = campaign_type_get_or_create(name="Testing campaign") CampaignRecipe = Recipe( "Campaign", phase_set=related(PhaseRecipe, EntryPhaseRecipe, RegistrationPhaseRecipe), campaign_type=campaign_type, ) def campaign_get_or_create(**kwargs): def get_campaign(): try: campaign = Campaign.objects.get(**kwargs) except Campaign.DoesNotExist: campaign = CampaignRecipe.make(**kwargs) return campaign return get_campaign
default_decimal_field=seq(Decimal('20.1')), default_int_field=seq(10), default_float_field=seq(1.23)) 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), ) dog_lady = Recipe(Person, dog_set=related('dog', other_dog))
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')) dog_with_friends = dog.extend(friends_with=related(dog, dog), ) extended_dog = dog.extend(breed='Super basset', ) other_dog_unicode = Recipe(Dog, breed='Basset', owner=foreign_key(u('person'))) dummy_unique_field = Recipe( DummyUniqueIntegerFieldModel, value=seq(10), ) dog_lady = Recipe(Person, dog_set=related('dog', other_dog))
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))
circumcised = Recipe( Circumcised, circ_date=date.today(), when_circ=15, age_unit_circ='Years', where_circ='not_sure', why_circ='Prevent HIV/AIDS', ) circumcision = Recipe( Circumcision, circumcised=YES, last_seen_circumcised=YES, circumcised_datetime=get_utcnow().date(), circumcised_location='Bokaa', health_benefits_smc=related(circumcision_benefits), ) cliniquestionnaire = Recipe( ClinicQuestionnaire, know_hiv_status=YES, current_hiv_status=POS, on_arv=YES, arv_evidence=YES, ) neighbourhood_problem = Recipe(NeighbourhoodProblems, name='Water', short_name="Water") communityengagement = Recipe(
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))
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))
) 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), ) dog_lady = Recipe(Person, dog_set = related('dog', other_dog) )
from model_mommy.recipe import Recipe, foreign_key, related from certifications.models import Vendor, Certification, Exam vendor_recipe = Recipe(Vendor, title='Test', description='Test') certification_recipe = Recipe(Certification, title='Test', description='Test', number='test-1', vendor=foreign_key(vendor_recipe)) exam_recipe = Recipe(Exam, title='Test', description='Test', number='test-1') exam_with_certification = exam_recipe.extend(certification=related(certification_recipe))
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')
other_dog = Recipe(Dog, breed = 'Basset', owner = foreign_key('person') ) other_dog_unicode = Recipe(Dog, breed = 'Basset', owner = foreign_key(u('person')) ) dummy_related_unique = Recipe dummy_unique_field = Recipe(DummyUniqueIntegerFieldModel, value = seq(10), ) dog_lady = Recipe(Person, dog_set = related('dog', other_dog) ) food_types = ["oranges", "lemons", "baking flower", "sugar"] ingredient_recipe = Recipe(Ingredient, amount = seq(1), food_type = cycle(food_types) ) cake_recipe = Recipe(Cake, ingredients=related(ingredient_recipe, ingredient_recipe, ingredient_recipe, ingredient_recipe) )
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')
user = Recipe( ChUser, date_joined=get_random_stuff.get_random_date, email=get_random_stuff.get_random_email, username=get_random_stuff.get_random_username, ) tag = Recipe( TagModel, tag=get_random_stuff.get_random_tag, ) category = Recipe( ChCategory, code=get_random_stuff.get_random_category_code, ) hive = Recipe( ChHive, category=foreign_key(category), creation_date=get_random_stuff.get_random_date, creator=foreign_key(user), description=get_random_stuff.get_random_hive_description, priority=get_random_stuff.get_random_hive_priority, name=get_random_stuff.get_random_hive_name, # The model layer should decide if create a new tag (if it didn't exist) or get existing tag (establish # many-to-many relationship) tags=related(tag, tag, tag), )
subjectrequisition = Recipe(SubjectRequisition) microbiology = Recipe( Microbiology, urine_culture_performed=NO, blood_culture_performed=NO, sputum_results_culture=NEG, tissue_biopsy_taken=NO, ) patienthistory = Recipe( PatientHistory, headache_duration=2, visual_loss_duration=1, tb_history=YES, symptom=related(symptom), neurological=related(neurological), tb_site="pulmonary", tb_treatment=YES, taking_rifampicin=NO, taking_arv=NO, patient_adherence=NO, last_dose=1, temp=38, heart_rate=88, respiratory_rate=22, weight=60, glasgow_coma_score=8, visual_acuity_day=date.today, left_acuity=0.52, right_acuity=0.53,
urine_culture_performed=NO, blood_culture_performed=NO, sputum_results_culture=NEG, tissue_biopsy_taken=NO,) symptom = Recipe( Symptom, name='vomiting', short_name='vomiting') patienthistory = Recipe( PatientHistory, headache_duration=2, visual_loss_duration=1, tb_history=YES, symptom=related(symptom), neurological=related(neurological), tb_site='pulmonary', tb_treatment=YES, taking_rifampicin=NO, taking_arv=NO, patient_adherence=NO, last_dose=1, temp=38, heart_rate=88, respiratory_rate=22, weight=60, glasgow_coma_score=8, visual_acuity_day=get_utcnow, left_acuity=0.52, right_acuity=0.53,
criterio_questionario = Recipe(models.CriterioQuestionario, numero=seq(1), descricao_questao=seq("Pergunta ")) criterio_alternativa = Recipe( models.CriterioAlternativa, posicao=seq(1), criterio=foreign_key(criterio_questionario), descricao_alternativa=seq("Alternativa "), ) modelo_questionario = Recipe(models.ModeloQuestionario, edital=foreign_key(edital), nome=seq("Modelo "), itens_avaliados=related(criterio_questionario)) inscricao = Recipe(models.Inscricao, candidato=foreign_key(candidato), edital=foreign_key(edital), aceite=True, curso=foreign_key(curso_psct), modalidade_cota=foreign_key(modalidade)) pontuacao_inscricao = Recipe(models.PontuacaoInscricao, inscricao=foreign_key(inscricao)) nota_anual = Recipe(models.NotaAnual, pontuacao=foreign_key(pontuacao_inscricao)) comprovante = Recipe(models.Comprovante,
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')) dog_with_friends = dog.extend(friends_with=related(dog, dog), ) extended_dog = dog.extend(breed='Super basset', ) other_dog_unicode = Recipe(Dog, breed='Basset', owner=foreign_key(u('person'))) dummy_unique_field = Recipe( DummyUniqueIntegerFieldModel, value=seq(10), ) dog_lady = Recipe(Person, dog_set=related('dog', other_dog)) nullable_related = Recipe('generic.DummyBlankFieldsModel', dummynullfieldsmodel_set=related( Recipe('generic.DummyNullFieldsModel')))
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', ) other_dog_unicode = Recipe(Dog, breed = 'Basset', owner = foreign_key(u('person')) )
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') ) dog_with_friends = dog.extend( friends_with=related(dog, dog), ) extended_dog = dog.extend( breed = 'Super basset', ) other_dog_unicode = Recipe(Dog, breed = 'Basset', owner = foreign_key(u('person')) ) dummy_unique_field = Recipe(DummyUniqueIntegerFieldModel, value = seq(10), )