Пример #1
0
 def test_new_entry(self):
     """
     Unit test for :meth:`ZoteroIngest._new_entry`\.
     """
     ingester = ZoteroIngest(self.rdf_path)
     before = len(ingester.data)
     ingester._new_entry()
     after = len(ingester.data)
     self.assertEqual(after, before + 1,
                      "A new entry should be added to ingester.data")
Пример #2
0
    def test_set_value(self):
        """
        Unit test for :meth:`ZoteroIngest._set_value`\.
        """
        ingester = ZoteroIngest(self.rdf_path)
        ingester._new_entry()
        ingester._set_value("key", "value")

        self.assertIn("key", ingester.data[-1],
                      "_set_value should add the key to the current entry.")
        self.assertEqual(ingester.data[-1]["key"], ["value"],
                         "_set_value should add the value to a list")
Пример #3
0
    def test_handle(self):
        """
        Unit test for :meth:`ZoteroIngest.handle`\.
        """
        ingester = ZoteroIngest(self.rdf_path)
        ingester.graph = self.g
        ingester._new_entry()  # Need somewhere to put the value.
        predicate, value = ingester.handle(DC.identifier, self.ident)
        self.assertEqual(
            value, self.test_uri,
            "handle() should pass along the predicate and value to"
            " handle_identifier(), and return native Python types.")

        predicate, value = ingester.handle(DC.nonsense, "value")
        self.assertEqual(
            predicate, DC.nonsense.toPython(),
            "If there are no special handlers for the predicate, it should be"
            " returned as a native Python type.")
        self.assertEqual(value, "value",
                         "So too with the corresponding value.")