Ejemplo n.º 1
0
 def test_set(self):
     a = Metadata()
     a["title"] = [("eng", "Epigrams")]
     self.assertEqual(a["title"]["eng"], "Epigrams")
     self.assertEqual(
         a.keys(), ["title"], "Keys should be set"
     )
     a[("desc", "label")] = ([("eng", "desc")], [("eng", "lbl"), ("fre", "label")])
     self.assertEqual(a["desc"]["eng"], "desc")
     self.assertEqual(a["label"][("eng", "fre")], ("lbl", "label"))
Ejemplo n.º 2
0
    def test_init(self):
        a = Metadata()
        self.assertTrue(hasattr(a, "metadata"), True)
        self.assertTrue(isinstance(a.metadata, defaultdict))

        a = Metadata(keys=["title"])
        self.assertTrue(isinstance(a.metadata["title"], Metadatum))
        self.assertEqual(
            a.keys(), ["title"], "Keys should be set"
        )