def test_m2m_towards_self_referencing_model(self): parent_obj = ManyToManyTowardsSelfReference.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=SelfReferencingManyToManyModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_many_to_many_relationship_with_declared_related_name(self): parent_obj = ManyToManyTargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManySourceModel, ) self.assertManagersEqual(manager, parent_obj.sources)
def test_many_to_many_relationship_with_self(self): parent_obj = SelfReferencingManyToManyModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=SelfReferencingManyToManyModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_generic_foreign_key_relationship(self): parent_obj = TargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=GenericForeignKeySourceModel, ) self.assertManagersEqual(manager, parent_obj.generic_sources)
def test_generic_foreign_key_relationship(self): parent_obj = TargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=GenericForeignKeySourceModel, ) self.assertManagersEqual(manager, parent_obj.generic_sources)
def test_many_to_many_relationship_from_other_side_without_related_name(self): parent_obj = ManyToManySourceNoRelatedNameModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManyTargetModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_many_to_many_relationship_with_declared_related_name(self): parent_obj = ManyToManyTargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManySourceModel, ) self.assertManagersEqual(manager, parent_obj.sources)
def test_foreign_key_relationship_without_related_name(self): parent_obj = TargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ForeignKeySourceNoRelatedNameModel, ) self.assertManagersEqual(manager, parent_obj.foreignkeysourcenorelatednamemodel_set)
def test_m2m_towards_self_referencing_model(self): parent_obj = ManyToManyTowardsSelfReference.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=SelfReferencingManyToManyModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_many_to_many_relationship_with_self(self): parent_obj = SelfReferencingManyToManyModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=SelfReferencingManyToManyModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_many_to_many_relationship_from_other_side_without_related_name( self): parent_obj = ManyToManySourceNoRelatedNameModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManyTargetModel, ) self.assertManagersEqual(manager, parent_obj.targets)
def test_foreign_key_relationship_without_related_name(self): parent_obj = TargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ForeignKeySourceNoRelatedNameModel, ) self.assertManagersEqual( manager, parent_obj.foreignkeysourcenorelatednamemodel_set)
def get_parent_to_child_manager(self, parent_obj): if self.parent_to_child_manager_attr is not None: return getattr(parent_obj, self.parent_to_child_manager_attr) else: return utils.find_parent_to_child_manager( parent_obj=parent_obj, child_model=self.model, )
def get_parent_to_child_manager(self, parent_obj): if self.parent_to_child_manager_attr is not None: return getattr(parent_obj, self.parent_to_child_manager_attr) else: return utils.find_parent_to_child_manager( parent_obj=parent_obj, child_model=self.model, )
def test_many_to_many_relationship_without_related_name(self): parent_obj = ManyToManyTargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManySourceNoRelatedNameModel, ) self.assertManagersEqual( manager, parent_obj.manytomanysourcenorelatednamemodel_set, )
def test_many_to_many_relationship_without_related_name(self): parent_obj = ManyToManyTargetModel.objects.create() manager = find_parent_to_child_manager( parent_obj=parent_obj, child_model=ManyToManySourceNoRelatedNameModel, ) self.assertManagersEqual( manager, parent_obj.manytomanysourcenorelatednamemodel_set, )