예제 #1
0
    def test_event_with_subject_seo(self):
        event = Event({
            'subject': NodeContext(Node(), {
                'name': 'the name',
                'seo': {
                    'metas': {
                        'name': {
                            'keywords': 'list, of, keywords'
                        }
                    }
                }
            })
        })

        SeoListener(SeoPage("site - %s", {
            'name': {
                'description': 'The description'
            }
        })).listener(event)

        self.assertTrue(event.has('node'))

        node = event.get('node')
        self.assertEquals(node.seo['title'], "site - the name")
        self.assertEquals(node.seo['metas'], {
            'name': {
                'keywords': 'list, of, keywords',
                'description': 'The description'
            }
        })
예제 #2
0
    def test_event_with_subject(self):

        event = Event({
            'subject': NodeContext(Node())
        })

        SeoListener(SeoPage()).listener(event)

        self.assertTrue(event.has('node'))

        node = event.get('node')
        self.assertEquals(node.seo['title'], u"\u2605")
        self.assertEquals(node.seo['metas'], {})
예제 #3
0
    def test_change_class(self):
        c = MetaCollection()
        c.add(Meta(NodeImage, 'image'))
        l = MetaListener(c)

        # valid type
        event = Event({'node': Node(None, {'type': 'image'})})
        l.on_node_load(event)
        self.assertEquals(event.get('node').__class__, NodeImage)

        # invalid type
        event = Event({'node': Node(None, {'type': 'fake'})})
        l.on_node_load(event)
        self.assertEquals(event.get('node').__class__, Node)
예제 #4
0
    def test_event_without_subject(self):
        event = Event()

        SeoListener(SeoPage()).listener(event)

        self.assertFalse(event.has('node'))