예제 #1
0
def add_reusable_text_snippet(slug, cls):
    snippet_with_heading = ReusableText(
        title='Test reusable text snippet with sidefoot heading',
        sidefoot_heading='Test sidefoot heading',
        text='A reusable snippet with a sidefoot heading',
    )
    snippet_without_heading = ReusableText(
        title='Test reusable text snippet without a sidefoot heading',
        text='A reusable snippet without a sidefoot heading.',
    )
    snippet_with_heading.save()
    snippet_without_heading.save()
    full_width_text = {
        'type':
        'full_width_text',
        'value': [{
            'type': 'reusable_text',
            'value': snippet_with_heading.id
        }, {
            'type': 'reusable_text',
            'value': snippet_without_heading.id
        }]
    }
    page = cls(
        title=slug,
        slug=slug,
    )
    page.content = StreamValue(
        page.content.stream_block,
        [full_width_text],
        True,
    )
    publish_page(page)
예제 #2
0
def add_reusable_text_snippet(slug, cls):
    snippet_with_heading = ReusableText(
        title='Test reusable text snippet with sidefoot heading',
        sidefoot_heading='Test sidefoot heading',
        text='A reusable snippet with a sidefoot heading',
    )
    snippet_without_heading = ReusableText(
        title='Test reusable text snippet without a sidefoot heading',
        text='A reusable snippet without a sidefoot heading.',
    )
    snippet_with_heading.save()
    snippet_without_heading.save()
    full_width_text = {
        'type': 'full_width_text',
        'value': [
            {
                'type': 'reusable_text',
                'value': snippet_with_heading.id
            },
            {
                'type': 'reusable_text',
                'value': snippet_without_heading.id
            }
        ]
    }
    page = cls(
        title=slug,
        slug=slug,
    )
    page.content = StreamValue(
        page.content.stream_block,
        [full_width_text],
        True,
    )
    publish_page(page)
예제 #3
0
 def test_context_with_about_us_snippet(self):
     about_us_snippet = ReusableText(title='About us (For consumers)')
     about_us_snippet.save()
     page = self.prepare_job_listing_page()
     test_context = page.get_context(HttpRequest())
     self.assertIn('about_us', test_context)
     self.assertEqual(test_context['about_us'], about_us_snippet)
예제 #4
0
 def test_context_with_about_us_snippet(self):
     about_us_snippet = ReusableText(title='About us (For consumers)')
     about_us_snippet.save()
     page = self.prepare_job_listing_page()
     test_context = page.get_context(HttpRequest())
     self.assertIn('about_us', test_context)
     self.assertEqual(
         test_context['about_us'],
         about_us_snippet
     )
예제 #5
0
 def test_english_page_context(self):
     from v1.models.snippets import ReusableText
     from ask_cfpb.models.pages import get_reusable_text_snippet
     rt = ReusableText(title='About us (For consumers)')
     rt.save()
     page = self.page1
     page.language = 'en'
     page.save()
     test_context = page.get_context(HttpRequest())
     self.assertEqual(test_context['about_us'],
                      get_reusable_text_snippet('About us (For consumers)'))
예제 #6
0
 def test_english_page_context(self):
     from v1.models.snippets import ReusableText
     from ask_cfpb.models.pages import get_reusable_text_snippet
     rt = ReusableText(title='About us (For consumers)')
     rt.save()
     page = self.page1
     page.language = 'en'
     page.save()
     test_context = page.get_context(HttpRequest())
     self.assertEqual(
         test_context['about_us'],
         get_reusable_text_snippet('About us (For consumers)'))