Exemplo n.º 1
0
class ClusterRecipes(ConversationRecipes):
    clusterization = Recipe(Clusterization,
                            conversation=_foreign_key(
                                ConversationRecipes.conversation))
    cluster = Recipe(Cluster,
                     clusterization=_foreign_key(clusterization),
                     name="cluster")
    stereotype = Recipe(
        Stereotype,
        name="stereotype",
        owner=_foreign_key(
            ConversationRecipes.author.extend(
                email="*****@*****.**")),
    )
    stereotype_vote = Recipe(
        StereotypeVote,
        author=stereotype.make,
        choice=Choice.AGREE,
        comment=_foreign_key(ConversationRecipes.comment),
    )

    def get_data(self, request):
        data = super().get_data(request)
        stereotype = self.stereotype.make(owner=data.author)
        votes = [
            self.stereotype_vote.make(author=stereotype, comment=comment)
            for comment in data.comments
        ]
        return record(data, stereotype=stereotype, stereotype_votes=votes)
Exemplo n.º 2
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),
        )
Exemplo n.º 3
0
    def setUp(self):
        """Set up test class."""
        self.factory = RequestFactory()
        StaffProfile.objects.rebuild()
        hr_group = mommy.make("auth.Group",
                              name=settings.SSHR_ADMIN_USER_GROUP_NAME)
        self.boss = mommy.make("auth.User",
                               first_name="Boss",
                               last_name="Lady",
                               email="*****@*****.**")
        self.boss.groups.add(hr_group)

        self.manager = mommy.make("auth.User",
                                  first_name="Jane",
                                  last_name="Ndoe",
                                  email="*****@*****.**")
        self.user = mommy.make("auth.User",
                               first_name="Bob",
                               last_name="Ndoe",
                               email="*****@*****.**")

        manager_mommy = Recipe(StaffProfile,
                               lft=None,
                               rght=None,
                               user=self.manager)

        staff_mommy = Recipe(StaffProfile, lft=None, rght=None, user=self.user)

        self.manager_profile = manager_mommy.make()

        self.staffprofile = staff_mommy.make()
Exemplo n.º 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))
Exemplo n.º 5
0
 def setUp(self):
     last_hour = datetime.now() - timedelta(hours=1)
     # Next hour has 1 minute more because the delay between
     # the creation of the event and the test execution
     next_hour = datetime.now() + timedelta(minutes=61)
     self.event_last_hour = Recipe(Event, ends=last_hour, published=True)
     self.event_next_hour = Recipe(Event, ends=next_hour, published=True)
     self.event_unpublished = Recipe(Event, ends=next_hour, published=False)
    def setup_method(self, test_method):

        self.apartamento = Recipe(
            ImovelVivaReal,
            tipo_imovel=ImovelVivaReal.TIPO_IMOVEL.apartamento,
        )
        self.casa = Recipe(
            ImovelVivaReal,
            tipo_imovel=ImovelVivaReal.TIPO_IMOVEL.casa,
        )
Exemplo n.º 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)
Exemplo n.º 8
0
class ClustersRecipes(EjRecipes):
    stereotype = Recipe(
        Stereotype,
        name='Stereotypeone',
        description='description?',
        conversation=_foreign_key(ConversationRecipes.conversation),
    )
    stereotype_vote = Recipe(StereotypeVote,
                             author=stereotype.make,
                             choice=Choice.AGREE,
                             comment=_foreign_key(ConversationRecipes.comment))
Exemplo n.º 9
0
    def setUp(self):
        djconfig.reload_maybe(
        )  # https://github.com/nitely/django-djconfig/issues/31#issuecomment-451587942

        User = get_user_model()
        self.teacher = Recipe(User, is_staff=True).make(
        )  # need a teacher or student creation will fail.
        self.student = mommy.make(User)
        self.assertion = mommy.make(BadgeAssertion)
        self.badge = Recipe(Badge, xp=20).make()

        self.badge_assertion_recipe = Recipe(BadgeAssertion,
                                             user=self.student,
                                             badge=self.badge)
Exemplo n.º 10
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
Exemplo n.º 11
0
 def _get_recipes(self):
     """
     Génération des recipes
     """
     recipes = []
     if self.recipes_data:
         for recipe_data in self.recipes_data:
             attrs = recipe_data.copy()
             for key, value in attrs.items():
                 if callable(value):
                     attrs[key] = value()
             recipes.append(Recipe(model, **attrs))
     else:
         recipes.append(Recipe(model))
     return recipes
Exemplo n.º 12
0
    def setUp(self):
        djconfig.reload_maybe()  # https://github.com/nitely/django-djconfig/issues/31#issuecomment-451587942

        User = get_user_model()
        self.teacher = Recipe(User, is_staff=True).make()  # need a teacher or student creation will fail.
        self.student = mommy.make(User)
        self.submission = mommy.make(QuestSubmission, quest__name="Test")
Exemplo n.º 13
0
    def test_contact_signal_is_called(self):
        with patch("pyjobs.marketing.models.new_contact") as mocked_contact:
            post_save.connect(mocked_contact, sender=Contact)

        self.contact = Recipe(Contact).make()

        self.assertTrue(mocked_contact.called)
Exemplo n.º 14
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)
Exemplo n.º 15
0
 def test_always_calls_with_quantity(self):
     with patch('test.generic.tests.test_recipes.choice') as choice_mock:
         l = ['foo', 'bar', 'spam', 'eggs']
         r = Recipe(DummyBlankFieldsModel,
                    blank_char_field=lambda: choice(l))
         r.make(_quantity=3)
         self.assertEqual(choice_mock.call_count, 3)
Exemplo n.º 16
0
class ProfileRecipes(EjRecipes):
    profile = Recipe(Profile)

    def get_data(self, request):
        data = super().get_data(request)
        profile = self.profile.make(user=data.user)
        return record(data, profile=profile)
Exemplo n.º 17
0
def aggregate_models():
    """Set up data for testing aggregate functions."""
    award_uri = [None, "yo", "yo", "yo"]
    award_fain = [None, None, "123"]
    award_piid = ["abc", "def", None]

    award_types = ["U", "B", "05", "B"]
    start_dates = [
        datetime.date(2016, 7, 13),
        datetime.date(2017, 1, 1),
        datetime.date(2018, 6, 1),
        datetime.date(2018, 1, 1),
    ]
    end_dates = [
        datetime.date(2018, 12, 31),
        datetime.date(2020, 1, 1),
        datetime.date(2050, 7, 14),
        datetime.date(2050, 7, 14),
    ]
    obligated_amts = [1000.01, 2000, None, 4000.02]

    # create awards
    award_recipe = Recipe(
        Award,
        piid=cycle(award_piid),
        fain=cycle(award_fain),
        uri=cycle(award_uri),
        type=cycle(award_types),
        period_of_performance_start_date=cycle(start_dates),
        period_of_performance_current_end_date=cycle(end_dates),
        total_obligation=cycle(obligated_amts),
    )

    award_recipe.make(_quantity=4)
Exemplo n.º 18
0
 def test_defining_recipes_str(self):
     from model_mommy.recipe import seq
     p = Recipe('generic.Person', name=seq('foo'))
     try:
         p.make(_quantity=5)
     except AttributeError as e:
         self.fail('%s' % e)
Exemplo n.º 19
0
class UserRecipes(EjRecipes):
    token = Recipe(PasswordResetToken,
                   url="random-data",
                   user=_foreign_key(EjRecipes.user))

    def get_data(self, request):
        data = super().get_data(request)
        return record(data, token=self.token.make(user=data.user))
Exemplo n.º 20
0
 def test_always_calls_with_quantity(self):
     with patch('tests.test_recipes.choice') as choice_mock:
         choice_mock.return_value = 'foo'
         lst = ['foo', 'bar', 'spam', 'eggs']
         r = Recipe(DummyBlankFieldsModel,
                    blank_char_field=lambda: choice_mock(lst))
         r.make(_quantity=3)
         assert choice_mock.call_count == 3
Exemplo n.º 21
0
class BoardRecipes(Base):
    board = Recipe(
        Board,
        slug='board-slug',
        title='Title',
        description='Description',
        owner=foreign_key(Base.author),
    )
Exemplo n.º 22
0
 def setUp(self):
     self.client = TenantClient(self.tenant)
     User = get_user_model()
     self.semester = mommy.make(Semester)
     self.teacher = Recipe(User, is_staff=True).make(
     )  # need a teacher or student creation will fail.
     self.student = mommy.make(User)
     self.submission = mommy.make(QuestSubmission, quest__name="Test")
Exemplo n.º 23
0
    def test_helper_send_feedback_collection_email(self, mocked_send_mail):
        from pyjobs.marketing.models import Contact, Messages

        self.feedback_email = Recipe(Messages, message_type="feedback").make()

        send_feedback_collection_email(self.job)

        self.assertTrue(mocked_send_mail.called)
Exemplo n.º 24
0
    def test_helper_send_offer_email_template(self, mocked_send_mail):
        from pyjobs.marketing.models import Contact, Messages

        self.offer_email = Recipe(Messages, message_type="offer").make()

        send_offer_email_template(self.job)

        self.assertTrue(mocked_send_mail.called)
Exemplo n.º 25
0
class EjRecipes(metaclass=FixtureMeta):
    """
    Base recipes for the site
    """
    user = Recipe(User,
                  is_superuser=False,
                  email='*****@*****.**',
                  name='user')
    author = Recipe(User,
                    is_superuser=False,
                    email='*****@*****.**',
                    name='author')
    root = Recipe(User,
                  is_superuser=True,
                  email='*****@*****.**',
                  is_staff=True,
                  name='root')
Exemplo n.º 26
0
def criar_dependencia_recipe_imovel(instance):
    instance.cidade = Recipe(Cidade, nome='Sao Jose dos Campos')
    instance.regiao = Recipe(Regiao,
                             nome='Oeste',
                             cidade=foreign_key(instance.cidade))
    instance.bairro = Recipe(Bairro,
                             nome='Aquarius',
                             regiao=foreign_key(instance.regiao))
    instance.proprietario = Recipe(Proprietario,
                                   nome='Roger Waters',
                                   fone='12998001002')
    instance.condominio = Recipe(Condominio,
                                 cep='12120000',
                                 logradouro='Rua Tubarão Branco',
                                 numero='900',
                                 bairro=foreign_key(instance.bairro),
                                 regiao=foreign_key(instance.regiao),
                                 cidade=foreign_key(instance.cidade))
    instance.apartamento_base = Recipe(
        Imovel,
        proprietario=foreign_key(instance.proprietario),
        tipo_imovel=Imovel.TIPO_IMOVEL.apartamento,
        dormitorios=2,
        cidade=foreign_key(instance.cidade),
        bairro=foreign_key(instance.bairro),
        complemento='Apto 14A')
    instance.casa = Recipe(Imovel,
                           proprietario=foreign_key(instance.proprietario),
                           tipo_imovel=Imovel.TIPO_IMOVEL.casa,
                           dormitorios=3,
                           cidade=foreign_key(instance.cidade),
                           bairro=foreign_key(instance.bairro))
Exemplo n.º 27
0
    def setUp(self):
        djconfig.reload_maybe(
        )  # https://github.com/nitely/django-djconfig/issues/31#issuecomment-451587942

        # needed because BadgeAssertions use a default that might not exist yet
        self.sem = mommy.make('courses.semester',
                              pk=djconfig.config.hs_active_semester)

        self.teacher = Recipe(User, is_staff=True).make(
        )  # need a teacher or student creation will fail.
        self.student = mommy.make(User)
        self.assertion = mommy.make(BadgeAssertion, semester=self.sem)
        self.badge = Recipe(Badge, xp=20).make()

        self.badge_assertion_recipe = Recipe(BadgeAssertion,
                                             user=self.student,
                                             badge=self.badge,
                                             semester=self.sem)
Exemplo n.º 28
0
 def test_always_calls_when_creating(self):
     with patch('test.generic.tests.test_recipes.choice') as choice_mock:
         choice.return_value = 'foo'
         l = ['foo', 'bar', 'spam', 'eggs']
         r = Recipe(DummyBlankFieldsModel,
                    blank_char_field=lambda: choice(l))
         r.make().blank_char_field
         r.make().blank_char_field
         self.assertEqual(choice_mock.call_count, 2)
Exemplo n.º 29
0
    def setUp(self):
        djconfig.reload_maybe(
        )  # https://github.com/nitely/django-djconfig/issues/31#issuecomment-451587942

        User = get_user_model()
        self.teacher = Recipe(User, is_staff=True).make(
        )  # need a teacher or student creation will fail.
        self.user = mommy.make(User)
        # Profiles are created automatically with each user, so we only need to access profiles via users
        self.profile = self.user.profile
Exemplo n.º 30
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)