Пример #1
0
 def test_quakeml_regex(self):
     """
     Tests that regex used to check for QuakeML validatity actually works.
     """
     # This one contains all valid characters. It should pass the
     # validation.
     res_id = (
         "smi:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
         "1234567890-.*()_~'/abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQR"
         "STUVWXYZ0123456789-.*()_~'+?=,;&")
     res = ResourceIdentifier(res_id)
     self.assertEqual(res_id, res.getQuakeMLURI())
     # The id has to valid from start to end. Due to the spaces this cannot
     # automatically be converted to a correct one.
     res_id = ("something_before smi:local/something  something_after")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # A colon is an invalid character.
     res_id = ("smi:local/hello:yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # Space as well
     res_id = ("smi:local/hello yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # Dots are fine
     res_id = ("smi:local/hello....yea")
     res = ResourceIdentifier(res_id)
     self.assertEqual(res_id, res.getQuakeMLURI())
     # Hats not
     res_id = ("smi:local/hello^^yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
Пример #2
0
 def test_quakeml_regex(self):
     """
     Tests that regex used to check for QuakeML validatity actually works.
     """
     # This one contains all valid characters. It should pass the
     # validation.
     res_id = (
         "smi:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
         "1234567890-.*()_~'/abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQR"
         "STUVWXYZ0123456789-.*()_~'+?=,;&")
     res = ResourceIdentifier(res_id)
     self.assertEqual(res_id, res.getQuakeMLURI())
     # The id has to valid from start to end. Due to the spaces this cannot
     # automatically be converted to a correct one.
     res_id = ("something_before smi:local/something  something_after")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # A colon is an invalid character.
     res_id = ("smi:local/hello:yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # Space as well
     res_id = ("smi:local/hello yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
     # Dots are fine
     res_id = ("smi:local/hello....yea")
     res = ResourceIdentifier(res_id)
     self.assertEqual(res_id, res.getQuakeMLURI())
     # Hats not
     res_id = ("smi:local/hello^^yea")
     res = ResourceIdentifier(res_id)
     self.assertRaises(ValueError, res.getQuakeMLURI)
Пример #3
0
 def test_resource_id_valid_quakemluri(self):
     """
     Test that a resource identifier per default (i.e. no arguments to
     __init__()) gets set up with a QUAKEML conform ID.
     """
     rid = ResourceIdentifier()
     self.assertEqual(rid.resource_id, rid.getQuakeMLURI())
Пример #4
0
 def test_resource_id_valid_quakemluri(self):
     """
     Test that a resource identifier per default (i.e. no arguments to
     __init__()) gets set up with a QUAKEML conform ID.
     """
     rid = ResourceIdentifier()
     self.assertEqual(rid.id, rid.getQuakeMLURI())