Example #1
0
 def test_from_path(self, tmpdir):
     """Put events should work with a path to a directory of events."""
     cat = obspy.read_events()
     event_path = Path(tmpdir) / "events.xml"
     bank1 = EventBank(event_path.parent / "catalog_dir1")
     bank2 = EventBank(event_path.parent / "catalog_dir2")
     # a slightly invalid uri is used, just ignore
     with suppress_warnings():
         cat.write(str(event_path), "quakeml")
     # test works with a Path instance
     bank1.put_events(event_path)
     assert Path(bank1.bank_path).exists()
     assert not bank1.read_index().empty
     # tests with a string
     bank2.put_events(str(event_path))
     assert Path(bank2.bank_path).exists()
     assert not bank2.read_index().empty
 def test_can_put_to_empty_bank(self, tmpdir):
     """ An empty bank should be init'able created when an event is
     put into it """
     path = Path(tmpdir) / "new_bank"
     bank = EventBank(path)
     assert not path.exists()
     cat = obspy.read_events()
     bank.put_events(cat)
     assert path.exists()
     assert len(bank.read_index()) == 3