Exemplo n.º 1
0
 def test_metadata(self):
     e = EntryBase(req_())
     self.eq_(e.get_metadata_keys(), STANDARD_FILTERS.keys())
     self.eq_(e.get_metadata("foo"), None)
     self.eq_(e.get_metadata("foo", "bar"), "bar")
     e.set_metadata("foo", "bar")
     self.eq_(e.get_metadata("foo"), "bar")
Exemplo n.º 2
0
 def test_metadata(self):
     e = EntryBase(req_())
     self.eq_(e.get_metadata_keys(), STANDARD_FILTERS.keys())
     self.eq_(e.get_metadata("foo"), None)
     self.eq_(e.get_metadata("foo", "bar"), "bar")
     e.set_metadata("foo", "bar")
     self.eq_(e.get_metadata("foo"), "bar")
Exemplo n.º 3
0
    def test_dictlike(self):
        e = EntryBase(req_())
        e["foo"] = "bar"
        e["body"] = "entry body"

        def sortlist(l):
            l.sort()
            return l

        self.eq_(sortlist(e.keys()),
                 sortlist(STANDARD_FILTERS.keys() + ["foo", "body"]))

        self.eq_(e["foo"], "bar")
        self.eq_(e.get("foo"), "bar")
        self.eq_(e.get("foo", "fickle"), "bar")
        self.eq_(e.get_metadata("foo"), "bar")
        self.eq_(e.get_metadata("foo", "fickle"), "bar")

        self.eq_(e["body"], "entry body", "e[\"body\"]")
        self.eq_(e.get("body"), "entry body", "e.get(\"body\")")
        self.eq_(e.getData(), "entry body", "e.getData()")

        self.eq_(e.get("missing_key", "default"), "default")
        self.eq_(e.get("missing_key"), None)

        # e.set("faz", "baz")
        # yield eq_, e.get("faz"), "baz"

        self.eq_(e.has_key("foo"), True)
        self.eq_(e.has_key("foo2"), False)
        self.eq_(e.has_key("body"), True)

        # FIXME - EntryBase doesn't support "in" operator.
        # self.eq_("foo" in e, True)
        # self.eq_("foo2" in e, False)
        # self.eq_("foo2" not in e, True)
        # self.eq_("body" in e, True)

        e.update({"foo": "bah", "faux": "pearls"})
        self.eq_(e["foo"], "bah")
        self.eq_(e["faux"], "pearls")

        e.update({"body": "new body data"})
        self.eq_(e["body"], "new body data")
        self.eq_(e.get_data(), "new body data")
Exemplo n.º 4
0
    def test_dictlike(self):
        e = EntryBase(req_())
        e["foo"] = "bar"
        e["body"] = "entry body"

        def sortlist(l):
            l.sort()
            return l

        self.eq_(sortlist(e.keys()), sortlist(STANDARD_FILTERS.keys() + ["foo", "body"]))

        self.eq_(e["foo"], "bar")
        self.eq_(e.get("foo"), "bar")
        self.eq_(e.get("foo", "fickle"), "bar")
        self.eq_(e.get_metadata("foo"), "bar")
        self.eq_(e.get_metadata("foo", "fickle"), "bar")

        self.eq_(e["body"], "entry body", "e[\"body\"]")
        self.eq_(e.get("body"), "entry body", "e.get(\"body\")")
        self.eq_(e.getData(), "entry body", "e.getData()")

        self.eq_(e.get("missing_key", "default"), "default")
        self.eq_(e.get("missing_key"), None)

        # e.set("faz", "baz")
        # yield eq_, e.get("faz"), "baz"

        self.eq_(e.has_key("foo"), True)
        self.eq_(e.has_key("foo2"), False)
        self.eq_(e.has_key("body"), True)

        # FIXME - EntryBase doesn't support "in" operator.
        # self.eq_("foo" in e, True)
        # self.eq_("foo2" in e, False)
        # self.eq_("foo2" not in e, True)
        # self.eq_("body" in e, True)

        e.update({"foo": "bah", "faux": "pearls"})
        self.eq_(e["foo"], "bah")
        self.eq_(e["faux"], "pearls")

        e.update({"body": "new body data"})
        self.eq_(e["body"], "new body data")
        self.eq_(e.get_data(), "new body data")