def testExampleZip(self): # URL and expected UUID as in # https://tools.ietf.org/id/draft-soilandreyes-arcp-02.html#rfc.appendix.A.2 self.assertEqual("arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/", generate.arcp_location("http://example.com/data.zip")) self.assertEqual( "arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/pics/", generate.arcp_location("http://example.com/data.zip", "/pics/")) self.assertEqual( "arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/pics/flower.jpeg", generate.arcp_location("http://example.com/data.zip", "/pics/flower.jpeg"))
def testLocationNamespaceUUIDstrPathQueryFrag(self): self.assertEqual( "arcp://uuid,215aa48f-233f-507f-8484-3eb5d6e23e9d/folder/file.txt?q=s#frag", generate.arcp_location(OID, "/folder/file.txt", "q=s", "frag", namespace=NAMESPACE_OID))
def testExampleZipUUIDValid(self): u = generate.arcp_location("http://example.com/") # Extract UUID to ensure it is v4 uuidStr = u.replace("arcp://uuid,", "").strip("/") # Ensure RFC4122 compliance self.assertIsNotNone(re.match(uuid_re, uuidStr)) # ensure lower-case in output self.assertEqual(uuidStr, uuidStr.lower()) # must be valid UUID uuid = UUID(uuidStr) # must be RFC_4122 variant, version 5 (name sha1) self.assertEqual(RFC_4122, uuid.variant) self.assertEqual(5, uuid.version)
def testLocationOtherNamespace(self): u = generate.arcp_location(OID, namespace=NAMESPACE_OID, path="/example") self.assertEqual( "arcp://uuid,215aa48f-233f-507f-8484-3eb5d6e23e9d/example", u)