def setUp(self):
        self.mk_main()
        self.request = RequestFactory().get('/')
        self.request.user = self.login()
        session_middleware = SessionMiddleware()
        session_middleware.process_request(self.request)
        self.request.session.save()

        self.section = SectionPage(title='test section')
        self.section_index.add_child(instance=self.section)

        self.important_tag = Tag(title='important tag')
        self.another_tag = Tag(title='other tag')
        self.tags = [self.important_tag, self.another_tag]
        for tag in self.tags:
            self.tag_index.add_child(instance=tag)
            tag.save_revision()

        self.page = ArticlePage(title='test article')
        self.section.add_child(instance=self.page)
        self.page.save_revision()

        for tag in self.tags:
            ArticlePageTags.objects.create(
                tag=tag,
                page=self.page,
            )

        self.adapter = PersistentFormsSegmentsAdapter(self.request)
Example #2
0
 def mk_sections(self, parent, count=2, **kwargs):
     sections = []
     for i in range(count):
         data = {}
         data.update({
             'title': 'Test Section %s' % (i, ),
         })
         data.update(kwargs)
         data.update({
             'slug': generate_slug(data['title']),
         })
         section = SectionPage(**data)
         parent.add_child(instance=section)
         section.save_revision().publish()
         sections.append(section)
     return sections
    def setUp(self):
        # Fabricate a request with a logged-in user
        # so we can use it to test the segment rule
        self.mk_main()
        self.request_factory = RequestFactory()
        self.request = self.request_factory.get('/')
        self.request.user = get_user_model().objects.create_user(
            username='******', email='*****@*****.**', password='******')
        middleware = SessionMiddleware()
        middleware.process_request(self.request)
        self.request.session.save()

        self.section = SectionPage(title='test section')
        self.section_index.add_child(instance=self.section)

        self.tag = Tag(title='test')
        self.tag_index.add_child(instance=self.tag)
        self.tag.save_revision()

        self.article = self.add_article(title='test article', tags=[self.tag])

        self.adapter = get_segment_adapter(self.request)