1from atpasser import did, handle, nsid, recordKeys, uri 2 3testStrings, testMethods = {}, {} 4 5testStrings[ 6 "did" 7] = """did:plc:z72i7hdynmk6r22z27h6tvur 8did:web:blueskyweb.xyz 9did:method:val:two 10did:m:v 11did:method::::val 12did:method:-:_:. 13did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N 14did:METHOD:val 15did:m123:val 16DID:method:val 17did:method: 18did:method:val/two 19did:method:val?two 20did:method:val#two""" 21testMethods["did"] = did.DID 22 23testStrings[ 24 "handle" 25] = """jay.bsky.social 268.cn 27name.t--t 28XX.LCS.MIT.EDU 29a.co 30xn--notarealidn.com 31xn--fiqa61au8b7zsevnm8ak20mc4a87e.xn--fiqs8s 32xn--ls8h.test 33example.t 34jo@hn.test 35💩.test 36john..test 37xn--bcher-.tld 38john.0 39cn.8 40www.masełkowski.pl.com 41org 42name.org. 432gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion 44laptop.local 45blah.arpa""" 46testMethods["handle"] = handle.Handle 47 48testStrings[ 49 "nsid" 50] = """com.example.fooBar 51net.users.bob.ping 52a-0.b-1.c 53a.b.c 54com.example.fooBarV2 55cn.8.lex.stuff 56com.exa💩ple.thing 57com.example 58com.example.3""" 59testMethods["nsid"] = nsid.NSID 60 61testStrings[ 62 "rkey" 63] = """3jui7kd54zh2y 64self 65example.com 66~1.2-3_ 67dHJ1ZQ 68pre:fix 69_ 70alpha/beta 71. 72.. 73#extra 74@handle 75any space 76any+space 77number[3] 78number(3) 79"quote" 80dHJ1ZQ==""" 81testMethods["rkey"] = recordKeys.RecordKey 82 83testStrings[ 84 "uri" 85] = """at://foo.com/com.example.foo/123 86at://foo.com/example/123 87at://computer 88at://example.com:3000 89at://foo.com/ 90at://user:pass@foo.com""" 91testMethods["uri"] = uri.URI 92 93for item in testMethods: 94 print(f"START TEST {item}") 95 for value in testStrings[item].splitlines(): 96 print(f"Value: {value}") 97 try: 98 print(f"str(): {str(testMethods[item](value))}") 99 except Exception as e: 100 print(f"× {e}")