def test_model_get_associated_content(self):
        TestSection.load_bulk(BASE_DATA)
        section = TestSection.objects.get(slug='2')
        article = TestArticle(title='1 Test Article', section=section)
        article.save()
        content = section.get_associated_content()
        self.assertTrue(len(content) == 5)
        child_sections = [s for s in content if s[3] == 'subsection']
        self.assertEqual(len(section.get_children()), len(child_sections))
        for s in section.get_children():
            self.assertTrue(s.slug in [s[0].slug for s in child_sections])
        child_articles = [s for s in content if s[2] == 'TestArticle']
        self.assertTrue(len(child_articles) == 1)
        self.assertEqual(child_articles[0][0].title, '1 Test Article')
        # Test the get_associated_content with an "only" argument.
        content = section.get_associated_content(only=["scaffold.TestArticle"])
        self.assertTrue(len(content) == 1)
        self.assertEqual(content[0][0].title, '1 Test Article')
        # Test the get_associated_content with a "sort_key" argument.
        content = section.get_associated_content(sort_key='title')
        self.assertEqual(
            [c[0].title for c in content],
            [u'1 Test Article', u'21', u'22', u'23', u'24']
        )
Test the BaseSection model's get_associated_content method
dataset/ETHPy150Open mazelife/django-scaffold/scaffold/tests.py/SectionTest.test_model_get_associated_content