# -*- encoding: utf-8 -*-
from __future__ import unicode_literals

from django.core.urlresolvers import reverse

from base.tests.test_utils import PermTestCase
from block.tests.scenario import default_scenario_block
from login.tests.scenario import default_scenario_login

from holding.tests.scenario import (
    get_holding_content,
    get_page_home,
    get_title_content,
    init_app_holding,
)


class TestViewPerm(PermTestCase):

    def setUp(self):
        default_scenario_block()
        init_app_holding()
        default_scenario_login()

    def test_content_publish(self):
        content = get_holding_content()
        url = reverse('holding.content.publish', kwargs={'pk': content.pk})
        self.assert_staff_only(url)

    def test_content_update(self):
        content = get_holding_content()
        url = reverse('holding.content.update', kwargs={'pk': content.pk})
        self.assert_staff_only(url)

    def test_footer_publish(self):
        content = get_title_content()
        url = reverse('holding.title.publish', kwargs={'pk': content.pk})
        self.assert_staff_only(url)

    def test_footer_update(self):
        content = get_title_content()
        url = reverse('holding.title.update', kwargs={'pk': content.pk})
        self.assert_staff_only(url)

    def test_home(self):
        url = reverse('project.home')
        self.assert_any(url)

    def test_page_design_home(self):
        page = get_page_home()
        url = reverse('project.page.design', kwargs=dict(page=page.slug))
        self.assert_staff_only(url)

@@ -153,16 +153,17 @@
 estCase%0A
+%0A
 from blo
@@ -175,102 +175,82 @@
 sts.
-scenario import default_scenario_block%0Afrom login.tests.scenario import default_scenario_login
+factories import PageFactory%0Afrom login.tests.factories import UserFactory
 %0A%0Afr
@@ -266,24 +266,25 @@
 g.tests.
-scenario
+factories
  import 
@@ -293,244 +293,474 @@
     
-get_h
+H
 olding
-_content,%0A    get_page_home,%0A    get_title_content,%0A    init_app_holding,%0A)%0A%0A%0Aclass TestViewPerm(PermTestCase):%0A%0A    def setUp(self):%0A        default_scenario_block()%0A        init_app_holding()%0A        default_scenario_login(
+Factory,%0A    TitleFactory,%0A)%0A%0A%0Aclass TestViewPerm(PermTestCase):%0A%0A    def setUp(self):%0A        UserFactory(%0A            username='admin',%0A            email='admin@pkimber.net',%0A            is_staff=True,%0A            is_superuser=True%0A        )%0A        UserFactory(username='staff', email='staff@pkimber.net', is_staff=True)%0A        UserFactory(%0A            username='web', email='web@pkimber.net',%0A            first_name='William', last_name='Webber'%0A        
 )%0A%0A 
@@ -807,36 +807,25 @@
    c
-ontent = get_holding_content
+ = HoldingFactory
 ()%0A 
@@ -879,38 +879,32 @@
  kwargs=%7B'pk': c
-ontent
 .pk%7D)%0A        se
@@ -978,36 +978,25 @@
    c
-ontent = get_holding_content
+ = HoldingFactory
 ()%0A 
@@ -1049,38 +1049,32 @@
  kwargs=%7B'pk': c
-ontent
 .pk%7D)%0A        se
@@ -1148,34 +1148,23 @@
    c
-ontent = get_title_content
+ = TitleFactory
 ()%0A 
@@ -1216,38 +1216,32 @@
  kwargs=%7B'pk': c
-ontent
 .pk%7D)%0A        se
@@ -1314,34 +1314,23 @@
    c
-ontent = get_title_content
+ = TitleFactory
 ()%0A 
@@ -1389,22 +1389,16 @@
 %7B'pk': c
-ontent
 .pk%7D)%0A  
@@ -1469,134 +1469,357 @@
     
-url = reverse('project.home')%0A        self.assert_any(url)%0A%0A    def test_page_design_home(self):%0A        page = get_page_home(
+PageFactory(%0A            slug='home', slug_menu='',%0A            template_name='holding/page_content.html',%0A        )%0A        url = reverse('project.home')%0A        self.assert_any(url)%0A%0A    def test_page_design_home(self):%0A        p = PageFactory(%0A            slug='home', slug_menu='',%0A            template_name='holding/page_content.html',%0A        
 )%0A  
@@ -1879,19 +1879,16 @@
 t(page=p
-age
 .slug))%0A

test - factory #660