3 ž}:až ใ@sŽdZddlZddlZddlmZGdd„dejƒZGdd„dejƒZGdd „d ejƒZGd d „d ejƒZ Gd d „d ejƒZ e dkrŠej ƒdS)zTests for josepy.util.้N)ฺ test_utilc@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)ฺComparableX509Testz%Tests for josepy.util.ComparableX509.cCsLtjdƒ|_tjdƒ|_tjdƒ|_tjdƒ|_tjdƒ|_tjdƒ|_dS)Nzcsr.pemz csr-san.pemzcert.pemz cert-san.pem) rZload_comparable_csrฺreq1ฺreq2ฺ req_otherZload_comparable_certฺcert1ฺcert2ฺ cert_other)ฺselfฉr ๚/usr/lib/python3.6/util_test.pyฺsetUp s      zComparableX509Test.setUpcCs|j|jjƒdƒdS)NT)ฺassertIsrZ has_expired)r r r r ฺtest_getattr_proxysz%ComparableX509Test.test_getattr_proxycCs$|j|j|jƒ|j|j|jƒdS)N)ฺ assertEqualrrrr)r r r r ฺtest_eqszComparableX509Test.test_eqcCs$|j|j|jƒ|j|j|jƒdS)N)ฺassertNotEqualrrrr )r r r r ฺtest_neszComparableX509Test.test_necCs |j|jdƒ|j|jdƒdS)N้)rrr)r r r r ฺtest_ne_wrong_types!sz&ComparableX509Test.test_ne_wrong_typescCsd|jt|jƒt|jƒƒ|jt|jƒt|jƒƒ|jt|jƒt|jƒƒ|jt|jƒt|jƒƒdS)N) rฺhashrrrrrrr )r r r r ฺ test_hash%szComparableX509Test.test_hashcCs2x,|j|jfD]}|jt|ƒdj|jƒƒqWdS)Nz)rrrฺreprฺformatฺwrapped)r Zx509r r r ฺ test_repr,s zComparableX509Test.test_reprN) ฺ__name__ฺ __module__ฺ __qualname__ฺ__doc__r rrrrrrr r r r r s rc@s`eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dS)ฺComparableRSAKeyTestz'Tests for josepy.util.ComparableRSAKey.cCs(tjdƒ|_tjdƒ|_tjdƒ|_dS)Nzrsa256_key.pemzrsa512_key.pem)rZload_rsa_private_keyฺkeyฺkey_sameฺkey2)r r r r r 5s  zComparableRSAKeyTest.setUpcCs|jd|jjƒdS)N้)rr!ฺkey_size)r r r r r;sz'ComparableRSAKeyTest.test_getattr_proxycCs|j|j|jƒdS)N)rr!r")r r r r r>szComparableRSAKeyTest.test_eqcCs|j|j|jƒdS)N)rr!r#)r r r r rAszComparableRSAKeyTest.test_necCs|j|jdƒdS)Nr)rr!)r r r r ฺtest_ne_different_typesDsz,ComparableRSAKeyTest.test_ne_different_typescCs|j|j|jjƒdS)N)rr!r"ฺ_wrapped)r r r r ฺtest_ne_not_wrappedGsz(ComparableRSAKeyTest.test_ne_not_wrappedcCs$ddlm}|j|dƒ|dƒƒdS)Nr)ฺComparableRSAKeyr)ฺ josepy.utilr)r)r r)r r r ฺtest_ne_no_serializationKs z-ComparableRSAKeyTest.test_ne_no_serializationcCsF|jt|jƒtƒ|jt|jƒt|jƒƒ|jt|jƒt|jƒƒdS)N)ฺassertIsInstancerr!ฺintrr"rr#)r r r r rOszComparableRSAKeyTest.test_hashcCs|jt|jƒjdƒdƒdS)Nz'.AฺxฺyN)r9r:)rrrฺ __slots__r r r r ฺA“sr<c@seZdZdZdS)z!ImmutableMapTest.setUp..Br9r:N)r9r:)rrrr;r r r r ฺB–sr=้้)r9r:)r:r9้้)r*r8r<r=ฺa1ฺa1_swapฺa2ฺb)r r8r<r=r r r r Žs zImmutableMapTest.setUpcCs>|j|jddd|jjddƒ|j|j|jjdddƒdS)Nr?)r9r:)r9r@rA)rr<rBฺupdaterD)r r r r ฺ test_updateกs zImmutableMapTest.test_updatecCs|jt|jjdƒdS)Nฺz)ฺ assertRaisesฺKeyErrorrBฺ __getitem__)r r r r ฺ&test_get_missing_item_raises_key_errorฅsz7ImmutableMapTest.test_get_missing_item_raises_key_errorcCs|j|j|jƒdS)N)rrBrC)r r r r ฺ"test_order_of_args_does_not_matterจsz3ImmutableMapTest.test_order_of_args_does_not_mattercCs(|jt|jdd|jt|jdddS)Nr>)r9r?)r:)rIฺ TypeErrorr<)r r r r ฺtest_type_error_on_missingซsz+ImmutableMapTest.test_type_error_on_missingcCs.|jt|jddd|jt|jdddddS)Nr>r?)r9rHr@)r9r:rH)rIrNr<)r r r r ฺtest_type_error_on_unrecognizedฏsz0ImmutableMapTest.test_type_error_on_unrecognizedcCsD|jd|jjƒ|jd|jjƒ|jd|jjƒ|jd|jjƒdS)Nr>r?)rrBr9r:rC)r r r r ฺ test_get_attrณszImmutableMapTest.test_get_attrcCs|jttj|jjdƒdƒdS)Nr9้ )rIฺAttributeErrorฺ functoolsฺpartialrBฺ __setattr__)r r r r ฺ$test_set_attr_raises_attribute_errorนsz5ImmutableMapTest.test_set_attr_raises_attribute_errorcCs4|j|j|jƒ|j|j|jƒ|j|j|jƒdS)N)rrBrDr)r r r r ฺ test_equalฝszImmutableMapTest.test_equalcCs|jtdƒt|jƒƒdS)Nr>r?)r>r?)rrrB)r r r r rยszImmutableMapTest.test_hashcCs|jt|jdidjƒdS)Nr>)r9r:)rIrNr<ฺ__hash__)r r r r ฺtest_unhashableลsz ImmutableMapTest.test_unhashablecCsT|jdt|jƒƒ|jdt|jƒƒ|jdt|jƒƒ|jdt|jdddƒƒdS)Nz A(x=1, y=2)z B(x=1, y=2)zB(x='foo', y='bar')ZfooZbar)r9r:)rrrBrCrEr=)r r r r rศszImmutableMapTest.test_reprN)rrrrr rGrLrMrOrPrQrWrXrrZrr r r r r7‹sr7c@sXeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dS)ฺfrozendictTestz!Tests for josepy.util.frozendict.cCsddlm}|ddd|_dS)Nr)ฺ frozendictr>ฺ2)r9r:)r*r\ฺfdict)r r\r r r r าs zfrozendictTest.setUpcCs(ddlm}|j|j|dddœƒƒdS)Nr)r\r>r])r9r:)r*r\rr^)r r\r r r ฺtest_init_dictึs zfrozendictTest.test_init_dictcCs&ddlm}|jt|ddijƒƒdS)Nr)r\ฺarE)r*r\rIrNฺitems)r r\r r r ฺ!test_init_other_raises_type_errorฺs z0frozendictTest.test_init_other_raises_type_errorcCs|jdt|jƒƒdS)Nr?)rฺlenr^)r r r r ฺtest_len฿szfrozendictTest.test_lencCs|jt|jƒtƒdS)N)r,rr^r-)r r r r rโszfrozendictTest.test_hashcCs$|jd|jjƒ|jd|jjƒdS)Nr>r])rr^r9r:)r r r r rๅsz!frozendictTest.test_getattr_proxycCs|jt|jjdƒdS)NrH)rIrSr^ฺ __getattr__)r r r r ฺ#test_getattr_raises_attribute_error้sz2frozendictTest.test_getattr_raises_attribute_errorcCs|jt|jjddƒdS)NrHr@)rIrSr^rV)r r r r ฺtest_setattr_immutable์sz%frozendictTest.test_setattr_immutablecCs|jdt|jƒƒdS)Nzfrozendict(x=1, y='2'))rrr^)r r r r r๏szfrozendictTest.test_reprN) rrrrr r_rbrdrrrfrgrr r r r r[ฯsr[ฺ__main__) rrTZunittestZjosepyrZTestCaserr r1r7r[rฺmainr r r r ฺs )+.D$