コード例 #1
0
def test_init_page_url_duplicate_change_name():
    page = PageFactory(name='Info 1', slug='info', slug_menu='')
    Url.objects.init_page_url(page)
    page.name = 'Info 2'
    page.save()
    url = Url.objects.init_page_url(page)
    assert 'Info 2' == url.title
コード例 #2
0
ファイル: test_template.py プロジェクト: pkimber/block
 def test_update_page(self):
     """'setup_page' will update a page with the new sections."""
     template = TemplateFactory()
     TemplateSectionFactory(template=template)
     page = PageFactory(template=template)
     self.assertEqual(0, page.pagesection_set.all().count())
     self.assertEqual(1, template.templatesection_set.all().count())
     page.refresh_sections_from_template()
     self.assertEqual(1, page.pagesection_set.all().count())
コード例 #3
0
ファイル: test_view_page.py プロジェクト: pkimber/block
def test_page_update(client):
    """Update a page and make sure the list of URLs is updated."""
    user = UserFactory(is_staff=True)
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    template = TemplateFactory()
    page = PageFactory(name='Orange', template=template)
    data = {
        'name': 'Apple',
        'order': 3,
        'template': template.pk,
    }
    response = client.post(reverse('block.page.update', args=[page.pk]), data)
    assert 302 == response.status_code, response.context['form'].errors
    assert reverse('block.page.list') == response['location']
    page.refresh_from_db()
    url = Url.objects.get(page=page)
    assert page.name == url.title
コード例 #4
0
ファイル: test_template.py プロジェクト: pkimber/block
 def test_update_pages_delete(self):
     """'setup_page' will update all the pages with the new sections."""
     section_a = SectionFactory(slug='a')
     section_b = SectionFactory(slug='b')
     section_c = SectionFactory(slug='c')
     template = TemplateFactory()
     TemplateSectionFactory(template=template, section=section_b)
     page = PageFactory(template=template)
     PageSectionFactory(page=page, section=section_a)
     PageSectionFactory(page=page, section=section_c)
     self.assertEqual(
         ['a', 'c'],
         [p.section.slug for p in page.pagesection_set.all()]
     )
     page.refresh_sections_from_template()
     self.assertEqual(
         ['b',],
         [p.section.slug for p in page.pagesection_set.all()]
     )
コード例 #5
0
def test_set_deleted():
    obj = PageFactory(slug="home", order=0)
    assert obj.deleted is False
    obj.set_deleted()
    assert obj.deleted is True