Ejemplo n.º 1
0
 def test_not_indexed(self):
     occurrence = CSVReader("data/occurrence.txt",
                            delimiter="\t",
                            quote_char="\"")
     with self.assertRaises(RuntimeError):
         records = list(
             occurrence.get_lines(
                 "eventID",
                 "Cruise68:Station593:EventSorbeSledge9887:Subsample16687"))
Ejemplo n.º 2
0
 def test_field_names_dict(self):
     names = {"scientificName": 7}
     occurrence = CSVReader("data/occurrence.txt",
                            delimiter="\t",
                            quote_char="\"",
                            index_fields=["scientificName"],
                            field_names=names)
     records = list(
         occurrence.get_lines("scientificName", "Neomysis integer"))
     self.assertTrue(records[0]["scientificName"] == "Neomysis integer")
     self.assertTrue(
         records[0]["col_6"] == "urn:lsid:marinespecies.org:taxname:120136")
Ejemplo n.º 3
0
    def test_read(self):
        occurrence = CSVReader("data/occurrence.txt",
                               delimiter="\t",
                               quote_char="\"",
                               index_fields=["id", "eventID"])

        indexes = occurrence.indexes()
        self.assertTrue("id" in indexes)
        self.assertTrue("eventID" in indexes)
        self.assertTrue(
            "Cruise68:Station593:EventSorbeSledge9887:Subsample16687" in
            indexes["eventID"])
        self.assertTrue(
            len(indexes["eventID"]
                ["Cruise68:Station593:EventSorbeSledge9887:Subsample16687"]) ==
            39)

        records = list(
            occurrence.get_lines(
                "id",
                "Cruise68:Station565:EventSorbeSledge9781:Subsample17409"))
        self.assertTrue(len(records) > 0)
        self.assertTrue(
            records[0]["eventID"] ==
            "Cruise68:Station565:EventSorbeSledge9781:Subsample17409")
        self.assertTrue(records[0]["scientificNameID"] ==
                        "urn:lsid:marinespecies.org:taxname:131495")

        records = list(
            occurrence.get_lines(
                "eventID",
                "Cruise68:Station622:EventSorbeSledge10018:Subsample15224"))
        self.assertTrue(
            records[21]["eventID"] ==
            "Cruise68:Station622:EventSorbeSledge10018:Subsample15224")
        self.assertTrue(records[21]["scientificNameID"] ==
                        "urn:lsid:marinespecies.org:taxname:120144")
Ejemplo n.º 4
0
 def test_field_names_list(self):
     names = [
         "id", "basisOfRecord", "occurrenceID", "sex", "lifeStage",
         "eventID"
     ]
     occurrence = CSVReader("data/occurrence.txt",
                            delimiter="\t",
                            quote_char="\"",
                            index_fields=["eventID"],
                            field_names=names)
     records = list(
         occurrence.get_lines(
             "eventID",
             "Cruise68:Station593:EventSorbeSledge9887:Subsample16687"))
     self.assertTrue(
         records[0]["eventID"] ==
         "Cruise68:Station593:EventSorbeSledge9887:Subsample16687")
     self.assertTrue(records[0]["occurrenceID"] == "Ugenthyperbenthos51168")
     self.assertTrue(records[0]["col_6"] == "Sagitta elegans")