예제 #1
0
    def test_index_active(self):
        from hem.db import IDBSession
        from hiero.views.blog import EntryController
        from horus.interfaces import IUserClass
        from horus.interfaces import IActivationClass
        from hiero.interfaces import IHieroEntryClass
        from hiero.tests.models import User
        from hiero.tests.models import Entry
        from hiero.tests.models import Activation
        from hiero.tests.models import Series
        from hiero.tests.models import Category
        from hiero.interfaces import IHieroCategoryClass
        from hiero.interfaces import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)
        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()

        owner = User(username='******',
                     email='*****@*****.**',
                     password='******')

        self.session.add(owner)

        entry = Entry(owner=owner,
                      title='test entry',
                      content='hi',
                      html_content='hi<br />',
                      is_published=True)

        entry1 = Entry(owner=owner,
                       title='test entry 2',
                       content='hi',
                       html_content='hi<br />',
                       is_published=True)

        self.session.add(entry)
        self.session.add(entry1)

        self.session.flush()

        controller = EntryController(request)

        results = controller.index()

        entries = results['entries']

        assert len(entries) == 2
        assert entries[0] == entry
        assert entries[1] == entry1
예제 #2
0
    def test_detail(self):
        from hem.db                 import IDBSession
        from hiero.views.blog       import EntryController
        from horus.interfaces       import IUserClass
        from horus.interfaces       import IActivationClass
        from hiero.interfaces       import IHieroEntryClass
        from hiero.tests.models     import User
        from hiero.tests.models     import Entry
        from hiero.tests.models     import Activation
        from hiero.tests.models     import Category
        from hiero.tests.models     import Series
        from hiero.interfaces       import IHieroCategoryClass
        from hiero.interfaces       import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)

        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()
        request.matchdict = Mock()

        owner = User(username='******', email='*****@*****.**',
            password='******')

        self.session.add(owner)

        entry = Entry(owner=owner, title='test entry', content='hi',
            html_content='hi<br />', is_published=True
        )

        entry1 = Entry(owner=owner, title='test entry 2', content='hi',
            html_content='hi<br />', is_published=True
        )

        self.session.add(entry)
        self.session.add(entry1)

        self.session.flush()

        def get(key, default):
            if key == 'slug':
                return entry1.slug

        request.matchdict.get = get

        controller = EntryController(request)

        results = controller.detail()

        returned_entry = results['entry']
        returned_entry == entry
예제 #3
0
    def test_index_active(self):
        from hem.db                 import IDBSession
        from hiero.views.blog       import EntryController
        from horus.interfaces       import IUserClass
        from horus.interfaces       import IActivationClass
        from hiero.interfaces       import IHieroEntryClass
        from hiero.tests.models     import User
        from hiero.tests.models     import Entry
        from hiero.tests.models     import Activation
        from hiero.tests.models     import Series
        from hiero.tests.models     import Category
        from hiero.interfaces       import IHieroCategoryClass
        from hiero.interfaces       import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)
        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()

        owner = User(username='******', email='*****@*****.**',
                password='******')

        self.session.add(owner)

        entry = Entry(owner=owner, title='test entry', content='hi',
            html_content='hi<br />', is_published=True
        )

        entry1 = Entry(owner=owner, title='test entry 2', content='hi',
            html_content='hi<br />', is_published=True
        )

        self.session.add(entry)
        self.session.add(entry1)

        self.session.flush()

        controller = EntryController(request)

        results = controller.index()

        entries = results['entries']

        assert len(entries) == 2
        assert entries[0] == entry
        assert entries[1] == entry1
예제 #4
0
    def test_detail(self):
        from hem.db import IDBSession
        from hiero.views.blog import EntryController
        from horus.interfaces import IUserClass
        from horus.interfaces import IActivationClass
        from hiero.interfaces import IHieroEntryClass
        from hiero.tests.models import User
        from hiero.tests.models import Entry
        from hiero.tests.models import Activation
        from hiero.tests.models import Category
        from hiero.tests.models import Series
        from hiero.interfaces import IHieroCategoryClass
        from hiero.interfaces import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)

        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()
        request.matchdict = Mock()

        owner = User(username='******',
                     email='*****@*****.**',
                     password='******')

        self.session.add(owner)

        entry = Entry(owner=owner,
                      title='test entry',
                      content='hi',
                      html_content='hi<br />',
                      is_published=True)

        entry1 = Entry(owner=owner,
                       title='test entry 2',
                       content='hi',
                       html_content='hi<br />',
                       is_published=True)

        self.session.add(entry)
        self.session.add(entry1)

        self.session.flush()

        def get(key, default):
            if key == 'slug':
                return entry1.slug

        request.matchdict.get = get

        controller = EntryController(request)

        results = controller.detail()

        returned_entry = results['entry']
        returned_entry == entry
예제 #5
0
    def test_index_active_paging(self):
        from hem.db import IDBSession
        from hiero.views.blog import EntryController
        from horus.interfaces import IUserClass
        from horus.interfaces import IActivationClass
        from hiero.interfaces import IHieroEntryClass
        from hiero.tests.models import User
        from hiero.tests.models import Entry
        from hiero.tests.models import Activation
        from hiero.tests.models import Category
        from hiero.tests.models import Series
        from hiero.interfaces import IHieroCategoryClass
        from hiero.interfaces import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)

        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)
        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()
        request.matchdict = Mock()

        def get(key, default):
            if key == 'page':
                return 2

        request.matchdict.get = get

        owner = User(username='******',
                     email='*****@*****.**',
                     password='******')

        self.session.add(owner)

        entries = []

        for i in xrange(1, 21):
            entry = Entry(owner=owner,
                          title='test entry %s' % i,
                          content='hi',
                          html_content='hi<br />%s' % i,
                          is_published=True,
                          published_on='4/%s/2012' % i)

            self.session.add(entry)

            entries.append(entry)

        self.session.flush()

        controller = EntryController(request)

        results = controller.index()

        result_entries = results['entries']

        assert len(result_entries) == 10
        assert entries[0].title == result_entries[9].title
        assert not entries[12] in result_entries
예제 #6
0
    def test_index_active_paging(self):
        from hem.db                 import IDBSession
        from hiero.views.blog       import EntryController
        from horus.interfaces       import IUserClass
        from horus.interfaces       import IActivationClass
        from hiero.interfaces       import IHieroEntryClass
        from hiero.tests.models     import User
        from hiero.tests.models     import Entry
        from hiero.tests.models     import Activation
        from hiero.tests.models     import Category
        from hiero.tests.models     import Series
        from hiero.interfaces       import IHieroCategoryClass
        from hiero.interfaces       import IHieroSeriesClass

        self.config.registry.registerUtility(Category, IHieroCategoryClass)
        self.config.registry.registerUtility(Series, IHieroSeriesClass)

        self.config.registry.registerUtility(Entry, IHieroEntryClass)
        self.config.registry.registerUtility(self.session, IDBSession)
        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)

        self.config.add_route('hiero_entry_index', '/')

        request = testing.DummyRequest()
        request.matchdict = Mock()

        def get(key, default):
            if key == 'page':
                return 2

        request.matchdict.get = get

        owner = User(username='******', email='*****@*****.**',
                password='******')

        self.session.add(owner)

        entries = []

        for i in xrange(1, 21):
            entry = Entry(owner=owner, title='test entry %s' % i, content='hi',
                html_content='hi<br />%s' % i, is_published=True,
                published_on='4/%s/2012' % i
            )

            self.session.add(entry)

            entries.append(entry)

        self.session.flush()

        controller = EntryController(request)

        results = controller.index()

        result_entries = results['entries']

        assert len(result_entries) == 10
        assert entries[0].title == result_entries[9].title
        assert not entries[12] in result_entries