Example #1
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        weekly_home = home_page.add_child(instance=Weekly(
            title='Weekly',
            slug='weekly'
        ))

        editions = []
        for i in range(10):
            edition = weekly_home.add_child(instance=WeeklyEdition(
                title='Edition %s' % i,
                slug='edition-%s' % i
            ))

            editions.append(edition)

        articles = []
        for e in editions:
            articles_ = PostFactory.create_content(8,
                content_page=e,
                post_type=WeeklyArticle
            )

            articles = articles + articles_

        cls.editions = editions
Example #2
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        weekly_home = home_page.add_child(
            instance=Weekly(title='Weekly', slug='weekly'))

        cls.articles = PostFactory.create_content(8,
                                                  content_page=weekly_home,
                                                  post_type=WeeklyArticle)
Example #3
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        program = PostFactory.create_program(home_page=home_page)

        indepthpage = home_page.add_child(instance=AllInDepthHomePage(
            title='In Depth Home Page'
        ))

        indepthpage.add_child(instance=InDepthProject(
            title="In Depth Project",
            date=str(date.today())
        ))
        indepthpage.add_child(instance=InDepthProject(
            title="In Depth Project 2: same date, different id",
            date=str(date.today())
        ))
        for post in InDepthProject.objects.all():
            post.save()

        PostFactory.create_program_content(5,
            program=program,
            content_page_type=ProgramOtherPostsPage,
            post_type=OtherPost,
            content_page_data={'singular_title': 'Test Content', 'title': 'Test Contents'}
        )
        for post in OtherPost.objects.all():
            post.save()

        PostFactory.create_program_content(5,
            program=program,
            content_page_type=ProgramBlogPostsPage,
            post_type=BlogPost
        )
        for post in BlogPost.objects.all():
            post.save()

        PostFactory.create_program_content(5,
            program=program,
            content_page_type=ProgramPolicyPapersPage,
            post_type=PolicyPaper
        )
        for post in PolicyPaper.objects.all():
            post.save()


        PostFactory.create_program_content(5,
            program=program,
            content_page_type=ReportsHomepage,
            post_type=Report
        )
        for post in Report.objects.all():
            post.save()
Example #4
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        program = PostFactory.create_program(home_page=home_page)

        posts = PostFactory.create_program_content(
            50,
            program=program,
            content_page_type=ProgramBlogPostsPage,
            post_type=BlogPost,
            post_data={'title': 'Unique Query'})

        cls.posts = posts
Example #5
0
    def setUp(self):
        self.login()

        self.home_page = PostFactory.create_homepage()
        self.all_report_home = self.home_page.add_child(
            instance=AllReportsHomePage(title='Reports', slug='reports-home')
        )

        self.program = PostFactory.create_program(home_page=self.home_page)

        self.reports = PostFactory.create_program_content(10,
            program=self.program,
            content_page_type=ReportsHomepage,
            post_type=Report
        )
Example #6
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        program = PostFactory.create_program(home_page=home_page)

        report_home = PostFactory.create_program_content_page(
            program=program, content_page_type=ReportsHomepage)

        cls.report1 = PostFactory.create_content(1,
                                                 content_page=report_home,
                                                 post_type=Report)[0]

        cls.report2 = PostFactory.create_content(
            1,
            content_page=report_home,
            post_type=Report,
            post_data={
                'sections':
                [('section', {
                    'title':
                    'Section 1',
                    'body':
                    StreamValue(ReportBody(),
                                [('heading', 'Subsection 1'),
                                 ('paragraph', RichText('<p></p>')),
                                 ('heading', 'Subsection 2'),
                                 ('paragraph', RichText('<p></p>'))])
                }),
                 ('section', {
                     'title':
                     'Section 2',
                     'body':
                     StreamValue(ReportBody(), [
                         ('heading', 'Subsection 1'),
                         ('paragraph', RichText('<p>Paragraph \{\{1\}\}</p>')),
                         ('heading', 'Subsection 2'),
                         ('paragraph', RichText('<p>Paragraph \{\{2\}\}</p>'))
                     ])
                 })],
                'endnotes': [('endnote', {
                    'number': 1,
                    'note': RichText('<a>endnote 1</a>')
                }),
                             ('endnote', {
                                 'number': 2,
                                 'note': RichText('<a>endnote 2</a>')
                             })]
            })[0]
Example #7
0
    def setUp(self):
        self.login()

        self.home_page = PostFactory.create_homepage()
        self.all_other_posts_home = self.home_page.add_child(
            instance=AllOtherPostsHomePage(title='Other', slug='other-home'))

        self.program = PostFactory.create_program(home_page=self.home_page)

        self.other_posts = PostFactory.create_program_content(
            10,
            program=self.program,
            content_page_type=ProgramOtherPostsPage,
            post_type=OtherPost,
            content_page_data={'singular_title': 'Singular Title'})

        self.other_posts_home = ProgramOtherPostsPage.objects.first()
Example #8
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        program = PostFactory.create_program(home_page=home_page)

        topics = PostFactory.create_program_topics(6, program=program)

        subtopic = PostFactory.create_subtopics(1, parent_topic=topics[0])[0]

        subprogram = PostFactory.create_subprogram(program=program)

        person = PostFactory.create_person()

        fellow = PostFactory.create_person(person_data={
            'role': 'Fellow',
            'fellowship_year': 2016
        })

        former_person = PostFactory.create_person(person_data={'former': True})

        leader = PostFactory.create_person(person_data={'leadership': True})

        board_member = PostFactory.create_person(
            person_data={'role': 'Board Member'})

        PersonProgramRelationship(program=program, person=person).save()

        PersonSubprogramRelationship(subprogram=subprogram,
                                     person=person).save()

        PersonTopicRelationship(topic=topics[0], person=person).save()

        PersonTopicRelationship(topic=subtopic, person=person).save()

        PersonProgramRelationship(program=program, person=fellow).save()

        PersonSubprogramRelationship(subprogram=subprogram,
                                     person=fellow).save()

        PersonTopicRelationship(topic=topics[0], person=fellow).save()

        cls.topics = topics
        cls.subtopic = subtopic
Example #9
0
    def setUp(self):
        self.login()

        self.home_page = PostFactory.create_homepage()

        self.all_in_depth_home = self.home_page.add_child(
            instance=AllInDepthHomePage(title='In Depth Home Page'))

        self.indepthproject = self.all_in_depth_home.add_child(
            instance=InDepthProject(title="In Depth Project",
                                    date=str(date.today())))
        self.indepthproject.save()
Example #10
0
    def test_author_serialization(self):
        blog_post = BlogPost.objects.first()
        author1 = PostFactory.create_person(
            person_data={
                'title': 'Albert Zeta',
                'first_name': 'Albert',
                'last_name': 'Zeta'
            }
        )
        author2 = PostFactory.create_person(
            person_data={
                'title': 'Albert Alpha',
                'first_name': 'Albert',
                'last_name': 'Alpha'
            }
        )

        author_rel1 = PostAuthorRelationship(
            author=author1,
            post=blog_post
        )

        author_rel1.save()

        author_rel2 = PostAuthorRelationship(
            author=author2,
            post=blog_post
        )

        author_rel2.save()

        blog_post = BlogPost.objects.first()

        url = '/api/post/?id=%s' % str(blog_post.id)
        response = self.client.get(url)
        results = response.json()['results']

        # order should be the order that they were saved
        self.assertEqual(results[0]['authors'][0]['last_name'], 'Zeta')
Example #11
0
    def test_image_serialization(self):
        blog_post = BlogPost.objects.first()

        img = PostFactory.create_image('img.png')
        img_file = SimpleUploadedFile('fake_image.png', img.getvalue())
        custom_image = CustomImage(file=img_file)
        custom_image.save()

        blog_post.story_image = custom_image
        blog_post.save()

        url = '/api/post/?id=%s&story_image_rendition=small' % str(blog_post.id)
        response = self.client.get(url)
        result = response.json()['results'][0]

        self.assertTrue('fill-300x230.png' in result['story_image'])
Example #12
0
    def test_other_content_by_title_and_category(self):
        other_content_page = ProgramOtherPostsPage.objects.first()
        category = other_content_page.add_child(instance=OtherPostCategory(
            title='Foo'
        ))

        category.save()

        post = category.add_child(instance=OtherPost(
            **PostFactory.post_data()
        ))

        post.save()

        url = '/api/post/?other_content_type_title=Test%20Contents&category=Foo'
        response = self.client.get(url)

        self.assertEqual(len(response.json()['results']), 1)
Example #13
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()

        program = PostFactory.create_program(home_page=home_page)

        program2 = PostFactory.create_program(home_page=home_page)

        topics = PostFactory.create_program_topics(6, program=program)

        topics2 = PostFactory.create_program_topics(6, program=program2)

        subtopics = PostFactory.create_subtopics(8, parent_topic=topics[0])

        sub_subtopics = PostFactory.create_subtopics(3,
                                                     parent_topic=subtopics[0])

        cls.program = program
        cls.topics = topics
Example #14
0
    def setUpTestData(cls):
        home_page = PostFactory.create_homepage()
        subpage = home_page.add_child(instance=SubscribePage(
            title='Subscriptions'
        ))
        segment = subpage.add_child(instance=SubscriptionSegment(
            title='Sub Segment',
            SegmentID='0',
            ListID='0'
        ))

        program = PostFactory.create_program(home_page=home_page)
        cls.program = program
        program_about_home = program.add_child(instance=ProgramAboutHomePage(
            title='About',
            slug='about'
        ))

        cls.program_posts = PostFactory.create_program_content(5,
            program=program,
            content_page_type=ProgramBlogPostsPage,
            post_type=BlogPost
        )

        FeaturedProgramPage(
            program=program,
            page=cls.program_posts[0]
        ).save()

        SubscriptionProgramRelationship(
            subscription_segment=segment,
            program=program
        ).save()

        program_about = program_about_home.add_child(instance=ProgramAboutPage(
            title='About Subpage',
            slug='subpage',
            show_in_menus=True
        ))

        subprogram = PostFactory.create_subprogram(program=program)
        cls.subprogram = subprogram

        FeaturedSubprogramPage(
            program=subprogram,
            page=cls.program_posts[1]
        ).save()

        SubscriptionSubprogramRelationship(
            subscription_segment=segment,
            subprogram=subprogram
        ).save()

        subprogram_about_home = subprogram.add_child(instance=ProgramAboutHomePage(
            title='About',
            slug='about'
        ))

        subprogram_about = subprogram_about_home.add_child(instance=ProgramAboutPage(
            title='About Subpage',
            slug='subpage',
            show_in_menus=True
        ))