Exemplo n.º 1
0
    def test_hasnt_nested_relationship(self):
        relationship = Relationship(self.financial_adviser,
                                    related_name='clients')

        self.assertFalse(
            relationship.has_nested_relationship(
                Relationship.RelatedMeta('clients', self.active_client.pk),
                Relationship.RelatedMeta('financial_planning', None)))
Exemplo n.º 2
0
    def test_has_nested_relationsihp(self):
        self.financial_adviser.clients.add(self.active_client)
        self.active_client.financial_planning = self.financial_planning

        relationship = Relationship(self.financial_adviser,
                                    related_name='clients')

        self.assertTrue(
            relationship.has_nested_relationship(
                Relationship.RelatedMeta('clients', self.active_client.pk),
                Relationship.RelatedMeta('financial_planning', None)))
Exemplo n.º 3
0
    def test_get_nested_related(self):
        self.active_client.financial_planning = self.financial_planning
        self.financial_planning.patrimony = self.patrimony

        relationship = Relationship(self.active_client,
                                    related_name='financial_planning')

        last_related = relationship.get_nested_related(
            Relationship.RelatedMeta('financial_planning', None),
            Relationship.RelatedMeta('patrimony', None))

        self.assertEqual(last_related, self.patrimony)
Exemplo n.º 4
0
    def test_get_nested_related_none_related(self):
        self.financial_planning.patrimony = self.patrimony

        relationship = Relationship(self.active_client,
                                    related_name='financial_planning')

        with self.assertRaisesMessage(
                AttributeError, "Not possible getting nested related."
                " 'financial_planning' related name got"
                " a None object."):
            relationship.get_nested_related(
                Relationship.RelatedMeta('financial_planning', None),
                Relationship.RelatedMeta('patrimony', None))