Beispiel #1
0
    def update(self):

        dct = Metadata()
        dct.update({'hello.world': 1})

        assert 'hello' in dct
        assert dct.hello.world == 1
Beispiel #2
0
    def redirects(self):

        dct = Metadata()
        alist = [1, 2, 3]

        dct['foo'] = alist
        dct.redirect('foo', 'baz')

        assert 'foo' not in dct
        assert 'baz' in dct
        assert dct['baz'] == alist
Beispiel #3
0
    def __init__(self, conf, meta):

        self.props = Metadata((k, v) for k, v in iteritems(conf)
            if k in ['author', 'lang', 'email', 'date_format',
                     'entry_permalink', 'page_permalink'])

        self.props.update(meta)
        self.type = meta.get('type', 'entry')

        # redirect singular -> plural
        for key, to in [('tag', 'tags'), ('filter', 'filters'), ('template', 'layout')]:
            if key in self.props:
                self.props.redirect(key, to)

        self.filters = self.props.get('filters', [])
        self.hashvalue = hash(self.filename, self.title, self.date.ctime())
Beispiel #4
0
    def works(self):

        dct = Metadata()
        dct['hello.world'] = 1

        assert dct['hello']['world'] == 1
        assert dct.hello.world == 1

        try:
            dct.foo
            dct.foo.bar
        except KeyError:
            assert True
        else:
            assert False

        dct['hello.foreigner'] = 2

        assert dct['hello']['world'] == 1
        assert dct.hello.world == 1

        assert dct.hello.foreigner == 2
Beispiel #5
0
 def init(self):
     assert Metadata({'hello.world': 1}).hello.world == 1