From a2c0ec207ea7dfb3f4addd309ccb44591a91ff77 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Fri, 23 Nov 2018 11:37:01 +0000 Subject: [PATCH] billing: Use mock_stripe in test_attach_discount_to_realm. --- ...ttach_discount_to_realm:Charge.list.1.json | Bin 0 -> 2129 bytes ...h_discount_to_realm:Customer.create.1.json | Bin 0 -> 1337 bytes ...discount_to_realm:Customer.retrieve.1.json | Bin 0 -> 1337 bytes ...discount_to_realm:Customer.retrieve.2.json | Bin 0 -> 5437 bytes ...discount_to_realm:Customer.retrieve.3.json | Bin 0 -> 5437 bytes ...ach_discount_to_realm:Customer.save.1.json | Bin 0 -> 2138 bytes ...ach_discount_to_realm:Customer.save.2.json | Bin 0 -> 4802 bytes ..._discount_to_realm:Invoice.upcoming.1.json | Bin 0 -> 2854 bytes ..._discount_to_realm:Invoice.upcoming.2.json | Bin 0 -> 2857 bytes ...scount_to_realm:Subscription.create.1.json | Bin 0 -> 2160 bytes ...tach_discount_to_realm:Token.create.1.json | Bin 0 -> 826 bytes corporate/tests/test_stripe.py | 44 +++++++++++------- stubs/stripe/__init__.pyi | 7 +++ 13 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Charge.list.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.create.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.2.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.3.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.2.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.2.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Subscription.create.1.json create mode 100644 corporate/tests/stripe_fixtures/attach_discount_to_realm:Token.create.1.json diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Charge.list.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Charge.list.1.json new file mode 100644 index 0000000000000000000000000000000000000000..c6837caf84b2db651a617205d48db5de4237790a GIT binary patch literal 2129 zcma)7+iu)85PkPo2zm~Zy){ky)WB|npiOHyNRy^0h*@%Ev8G6tm$lc1|Gh(MEm5mA z(0wqBIppZf%$dW7v#P2E1gL+k{-Xb@>LLH7D0C+3K=B`5FBUJRQRc9TTA(1fz^ql0 zLy$&OTt}tGYa_%O#AA313N%L+9B2>xkf9EDnk_HD|8oAmU7UAc|Lyecd;9KB^XAJ{ zJ>=$KLv)!-a1qD2LkKy%{BE;eeZN@0*^FRx4mIBslRA1)WQ#tS4qXCx^z66auRgy0 z^~1NHFBXf%ay%!{b0_VoVhIXTpX`H>-o`MizX7SJ1jdbc7VFS^xSqofqF@38rSL@h z;c=)@rt#Fgo%Qf)aVgI6;^SD2)H@@2N?yx(&tG4Ec(=Q|+mGj!++o*~Z9w_4=^YU{ z=&4|0w*MecS|T>!sEC21(QJz?sD_z_@QG-Q6L}8PU<{n*Lua3qN?O$zZjHNPK0t`6 z3pH5l%nk+H?%4qyK1vrz8h)nI6qo*nDcqq-NwjetsL8#Adv07Juzae5E_zf79UF&K zU&6ja9V%jL6$X4+<_UY7n+-9v#>sn<>0!gh@ma_NoM_tiNtx7vaubJ1Zya(YNiyt6 z45@$?I{Nfa_fbjvl86ixr~&;^9lPzk$;En4$J+x(I&-*_czaC7x6)dvuV--+T~=B# zKM=x^ycw4vZ{#I#*+@Rnr3Md2k}J7<>a&)#-_<7?I{H&*mDIRQefUgX<*LwPx>R9LF-~4Qhbk)Y;?6)mqK$4hq z<)y;Vh(L)1bAwvmXZI&Np!H5eOHG|ExX+u=KYGo43A31zg^;`VZ;i>X(zmqD)wwcJ zRF@7r8H>G6mwE^Ek#ofKMn8?E&d)1-iCsGrlN1M9k3{b8bdD^;(?GMo4Xa;| VDb&$ri+QzMzUocg*JqDs{{aIlOJ4v0 literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.create.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.create.1.json new file mode 100644 index 0000000000000000000000000000000000000000..18131f2ce69221c299c73565db21ca8c690bd935 GIT binary patch literal 1337 zcmd6n+m6#P5QgvfDI!ZqAfautrD~QdkQN~%4icA(kmWiPYVaZTAuLq;?%3lb^>*Q& zt2Q(CA92;VZbZ-Iq@sRH+^3K<+DWx>+5#iTyL*Z*_?db1;)Ez*-X_N3nN%$d61++Q)RT@ zyYqL7BpCU5`0@7OT7SAJ#R$rDN!~>SEUDNXwa|e=EgscV;918!i}#NA3%q73RU+-? zN!867Em^bs4m`;{tF>eXh|`I)&SJHjOB^+FBnD7)SB@1EUMO&g2ny}6-Y)ek65raI;B?H=ap4@7v@I5-cjX8k^M&I+3 RjK=jBz2NgF0qu2v@dtgDd%pkx literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.1.json new file mode 100644 index 0000000000000000000000000000000000000000..18131f2ce69221c299c73565db21ca8c690bd935 GIT binary patch literal 1337 zcmd6n+m6#P5QgvfDI!ZqAfautrD~QdkQN~%4icA(kmWiPYVaZTAuLq;?%3lb^>*Q& zt2Q(CA92;VZbZ-Iq@sRH+^3K<+DWx>+5#iTyL*Z*_?db1;)Ez*-X_N3nN%$d61++Q)RT@ zyYqL7BpCU5`0@7OT7SAJ#R$rDN!~>SEUDNXwa|e=EgscV;918!i}#NA3%q73RU+-? zN!867Em^bs4m`;{tF>eXh|`I)&SJHjOB^+FBnD7)SB@1EUMO&g2ny}6-Y)ek65raI;B?H=ap4@7v@I5-cjX8k^M&I+3 RjK=jBz2NgF0qu2v@dtgDd%pkx literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.2.json new file mode 100644 index 0000000000000000000000000000000000000000..4bdce0f268acac05cd937b82b4025c2e81f4d03b GIT binary patch literal 5437 zcmc&&ZExE)5dPj@VGtOw0Yz)a&f*LhwqhBE0b4V)>ppZC1e&5_E_w?|d2x#V_uU;y ziIQl?`?P#<#5?hh_wqbPeR?sQF)l>iRyN!4f>%PaZ)WqCxGuEhR_5@$xLhqSuI9`2 z!Ur!e|7OlzN-oE?w%`ZQH{PAW!pD#MC zy+|9%4;3$!$O>-kYIp$o*kom0*&Qq|{dsZiAURsQm@mWXR#kUWH(FH|-59tKIk9c4 z95hh{DkWDoc&F&7g6n+fKAgb+bq5K4vem`vBD`Np%X4ly?ELAo_Y{tW31M$?j)kFh zP_8$BOF@33!LVxUds(R`ZdF}nu-~pmpD@#qXxfwI5=!Zzm2}80FN{P}uxx}@4Zeu> zp4vh+voAl=&yC!FMHX1D45bfUbfp824ZY%?v6xEgs(QQirrl9M5;xZJdc9m+UtRRV zzPb9!M8{f9$3d^QwU&D*lJ2D-%oH3KlWfK|T~hvexc}+FtV60`+d}PSS?3tsE(p{M zC4bByt+J$8O!iA833dx!K>tfV-8Rg1FtCKVmFasdS1#5lziV%qWKp$k8Z4ep; z0kNu-hFp{-q15uK+i%YcIS>d_&YP!?y))hl3o zQD)9k*N$${Sb`sNih;K4mp%kt3^Cly>{Qb@90&npjsvh}e0TVE{*!Fa{OSO5)ATS@ zIZY7*-P1HNRZYU_L~TeH1M!qH2I2&5jOE8&NYMwqouUvYIH$~=<`F6(;c+@4ae`91 z^$D$zOBguX-0pcqn5(F_UVzVHx1>jB5cbVI_Z6MD)a$w}HljnC8oe>t3j z?l*wedW5|Z*c8eHsAjgdyvPFU&>#lg*J{F%*Zalm(3S@O8#3?Wb?C^honv@9uTh(( zP{J|lRs#Gu$c7#dZI1^8mo}<^?sId&j_W&_@fI)_-W0qj4jpOrs+l;50@Nz8s}XuS zEL{aa2VH@)X_0Y@mQ|f+4x|U9)v3uG6sNAm#Oo*8feE7Ck%7hK)oMNedbvKKIU#|e z?irLrk<0nPWH1J+BFo$1{ORQ55qlK*j+-Vqfmj_0iR&b&hEc`DX@YUQ>}v#Ffk2NS z-K~b<$30;>rgw-aHcpLsAJlOdyyB5|_0qmCN~l~}sbQRgV=%(>#6g127@cCf z$+;v}09z;13-U^d`+&^6s#@?W;Z0u#l;ea(qwBnNmj?WoqOiJNy_fd)o8~dKr&Usq zN8sLhMq+?+8l#6z8MK&%JD`EVy?m~0tX2T@9^?=bAoNG}qyo(Bp}{JI2*V6*U=;RK zRxlkAn_FTJEeDjL`}lespYh;|&*R1%7;v2CcJ|EX&7}Fw3;Q%hEazoOuJf{p@g{9< zzKfT>J>_{6loO?StRy3jjx9!|!x8`kUs{ep%Nd~J?~@5Q35@$3kUR?^@Wo;JVaJ92 zY}hyr7@af?6(=%r3Lc&VhA3MTNMQc~3|yZl+VM01oYDHA@_f?+o&(>UX!p3L(=9%| zu10K(LfazTghK7Hfm!$*(2soc{(=sPan6q~%~&{I6y_s@F^?Vp-y|H}%T0g1#q+6Z YTSwWYGvitY-&*jSW%&L=$N2o>U-|HraR2}S literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.retrieve.3.json new file mode 100644 index 0000000000000000000000000000000000000000..4bdce0f268acac05cd937b82b4025c2e81f4d03b GIT binary patch literal 5437 zcmc&&ZExE)5dPj@VGtOw0Yz)a&f*LhwqhBE0b4V)>ppZC1e&5_E_w?|d2x#V_uU;y ziIQl?`?P#<#5?hh_wqbPeR?sQF)l>iRyN!4f>%PaZ)WqCxGuEhR_5@$xLhqSuI9`2 z!Ur!e|7OlzN-oE?w%`ZQH{PAW!pD#MC zy+|9%4;3$!$O>-kYIp$o*kom0*&Qq|{dsZiAURsQm@mWXR#kUWH(FH|-59tKIk9c4 z95hh{DkWDoc&F&7g6n+fKAgb+bq5K4vem`vBD`Np%X4ly?ELAo_Y{tW31M$?j)kFh zP_8$BOF@33!LVxUds(R`ZdF}nu-~pmpD@#qXxfwI5=!Zzm2}80FN{P}uxx}@4Zeu> zp4vh+voAl=&yC!FMHX1D45bfUbfp824ZY%?v6xEgs(QQirrl9M5;xZJdc9m+UtRRV zzPb9!M8{f9$3d^QwU&D*lJ2D-%oH3KlWfK|T~hvexc}+FtV60`+d}PSS?3tsE(p{M zC4bByt+J$8O!iA833dx!K>tfV-8Rg1FtCKVmFasdS1#5lziV%qWKp$k8Z4ep; z0kNu-hFp{-q15uK+i%YcIS>d_&YP!?y))hl3o zQD)9k*N$${Sb`sNih;K4mp%kt3^Cly>{Qb@90&npjsvh}e0TVE{*!Fa{OSO5)ATS@ zIZY7*-P1HNRZYU_L~TeH1M!qH2I2&5jOE8&NYMwqouUvYIH$~=<`F6(;c+@4ae`91 z^$D$zOBguX-0pcqn5(F_UVzVHx1>jB5cbVI_Z6MD)a$w}HljnC8oe>t3j z?l*wedW5|Z*c8eHsAjgdyvPFU&>#lg*J{F%*Zalm(3S@O8#3?Wb?C^honv@9uTh(( zP{J|lRs#Gu$c7#dZI1^8mo}<^?sId&j_W&_@fI)_-W0qj4jpOrs+l;50@Nz8s}XuS zEL{aa2VH@)X_0Y@mQ|f+4x|U9)v3uG6sNAm#Oo*8feE7Ck%7hK)oMNedbvKKIU#|e z?irLrk<0nPWH1J+BFo$1{ORQ55qlK*j+-Vqfmj_0iR&b&hEc`DX@YUQ>}v#Ffk2NS z-K~b<$30;>rgw-aHcpLsAJlOdyyB5|_0qmCN~l~}sbQRgV=%(>#6g127@cCf z$+;v}09z;13-U^d`+&^6s#@?W;Z0u#l;ea(qwBnNmj?WoqOiJNy_fd)o8~dKr&Usq zN8sLhMq+?+8l#6z8MK&%JD`EVy?m~0tX2T@9^?=bAoNG}qyo(Bp}{JI2*V6*U=;RK zRxlkAn_FTJEeDjL`}lespYh;|&*R1%7;v2CcJ|EX&7}Fw3;Q%hEazoOuJf{p@g{9< zzKfT>J>_{6loO?StRy3jjx9!|!x8`kUs{ep%Nd~J?~@5Q35@$3kUR?^@Wo;JVaJ92 zY}hyr7@af?6(=%r3Lc&VhA3MTNMQc~3|yZl+VM01oYDHA@_f?+o&(>UX!p3L(=9%| zu10K(LfazTghK7Hfm!$*(2soc{(=sPan6q~%~&{I6y_s@F^?Vp-y|H}%T0g1#q+6Z YTSwWYGvitY-&*jSW%&L=$N2o>U-|HraR2}S literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.1.json new file mode 100644 index 0000000000000000000000000000000000000000..61dbdfc37dc89d915643611d1bc893efdc3151b2 GIT binary patch literal 2138 zcmb_d+iDvz5Pi>AEP_G{A+fyNYp63_RSDL(Hfb(DTjbNT(^)t? zCZ9J*@zNXKqpGxlH5kIOku0Pt8m-*QZl5Uwm+bfL&AVH>aO2KeuA$LoV16KhN;dqi zFi=86Ts*7Sfa4{19QQpw4d4}TLM661d6AVpM?+RGe}M>e_iPQB7VzRw29d1A$q}i5 za0Cp{6wCC+DdA)TmLNhyO36=$dTU-&!_IghVmpXTc` z21evtT`}vp2`z2P6t`HvOqCRhArivDpy9F(5LUdY!M!1s9SPk;b;Y~d1CL3y)>1&x z8mQ!5s6s-Ybh_Skp)9?vs8^I=-4yYpq3;;9j_4s!Y`{EHFmM>?W_BgpR;r%~VJr?} z&`dWSol?Hj*;yB*TjXVFz}iAc7jBq+;X+nY3jllrx^ zecQ}w$Lpehb?7lfEZ&fh9IvOx{aD)YYs=V<`-#N!qXnh*v|~{J1H{h4{~cmtn0E9X ahwqS7l}_Zx`dERFU~r56VI-4%I`{(~uu3KX literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.2.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Customer.save.2.json new file mode 100644 index 0000000000000000000000000000000000000000..2e15484f70ced052739988d514b5b40cdac75065 GIT binary patch literal 4802 zcmc&&+in{-5Pi>A2m}hWKoINZS}IVqL0q5(+PH|DKBOoJic3jscDWmpD_A!C@15ag zmwS<{KGiRlc80^boH;YAr&p5+VVsw>vUJ08rnn&AO{TB$IoE<&k-_)b^>Q)4nJ!i{ zFQ~N^iXTBjYLgN7FcVu==a!nX*3JmwOlS1{-G|@a{`$+OpKhn=-z*-=rTS6}Wx>{# zO5e1Vuy0B+O zF6@sEWp8*{cy#$%op6sxbtoklw9;ZLAJB>e`ZVBrte_;Vmd7hVFfXXTsfpV^G}fiZ zIYk2o&<^B zC(Z#5EJD8pO-KAFD>S~qzcD93e%ghNW)6_#Pia_s+Hp|G$bCm}3Cx{?{J>9NoE@Q| zC8s$vb~y}AJXD@-K(vUxhwTH;kAfkJ=F>$g*#c06uC#Ql>w()cbi|=^Y+I|$!wRQC zCT$vD=#Up#9xZ`G(SNd>FXyS9v@aSKg9DMr-ewFzrdz57VbTfUKx)pGpM{c-j;ATu z-j|U_0`Q;R|Gxu8?3sc5=^pnc_H$`s*u<8W>K-4Swno+g0pH zxZhJyN>7(HYE|Wu`_Q%m=*Ls`5EUDlL-!#c5WZ)6Cn&3dbKxXsd45du6;vrd@*LC@ z-1g1jjR=&E8OVqT`;@8S+1tvE>>qW z2ScE%d%?(YFwNM}P~bS3)2tpLlfj4p#H3{ct}R-OxR#ob z9;N%IaryDzupG&%6BfB7H^Ef!L7sLYD4uB7AZ`0H1vf?SlW2l+1q&wtr0+1e%(#V} z2xPcCv;g$yP`=w~u>-cJwPCwqnOa4+0D_?vte+!>BKi%?9=|pLvZ4MRs%xyJnd~o( zQ3(^?u8+-v+=}rN@#)3{(A#qH@b0jAyj!jB%!fgiP+3`_VV#07h~xB;K%!2cozi>B z*j|z3Q-6dh8^0#DjbGQ zygC_d{t@|7Ghi9FaIO0J=`XJMz2BIf3;ay;mcwKV*No4%AZ*K&Ot~N%opnK$OuRvx zn;+6g-=Fh5Ny-^$o`PgDqthD`=#UYDIZZ7WkV<%;9HA3(A(3>*c#J~MlE;O#ah@<5 z={QxKsl+*Yc!?O2Y7HoX{0B1deLm8T=Lz6~)(4fBn;!Ta=FORQPcc2-;=|X~WE!K; z)<`!Is4X`T3qJ?6E8nzzL5IS4=ld_s*snnp_amgSz#aeJCY-#NoA&h<{Qbp+@%-vvscqqh literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.1.json new file mode 100644 index 0000000000000000000000000000000000000000..660f9f3b2c14f8e10fa0da829306f23e1623f820 GIT binary patch literal 2854 zcma)8+m0hO5PhGoXjveE1e?y})9ppuJo&SxipQJ**IeUb=?wk#@!c=q|NPVYA0F~NpN2CPvlz>C zv6>h8a#qa!1r^^iS6gb7)8#1Eikni47Sn)kqZ46L>@Sd8$T|GB{zUliSy0<8*rn8k zvk<2BX__u(>tZ%tukH~=*z5xv8C6buE)c|4X?}n(JEOEog`|y=c5lw_^rVvy&rd%- zo5J>%wK(ubRTy%|na9zvBhXPH&k*{BzlK`|sbpaH^4j5$tU*ttSbUyUDM#I|+Wf;y z)Jw`%x6^XSI!HDot6048^7J?m18?XCnI0v?iiR5xkvBe>vsLHsz-k|`)sFkbMu@12 z|56B0$0cgGzm4?B&!Qs6GL0ck7xUTuDxVe80D>5|843rT0TPdcKxNXX!*mJW338_! zRx{}p7%FrtB*gNOSCrv3-EpWXj-*8SMJoP`DoP^kWC$mhb0~t8AyjNHG~!|fc?o9Z zO!GzN4AzK(|y1&aVm))_ck@Ra8L78e#&)356{8sRE-w{B)Tw=l8`b^o9Td zHhZd5>xkKov_`Bg5P0sFl@{vkB6e`fc00{?&6T( zLk++Q0%1`nMPK0Pg_M^KC(1NpzO4nY4g_IX^g+#zZx5S~kHz}Yyc^^bk4eil6duAr z30&Xp-i$GT+XRE>8x+Hi6y;OuIZR3ixA)3|{ayr~mC;_SRpmlE!cQODd_Di2+dm%K zA z`DxWX6r+v~>3DWbT4Ax37JV+xTNVC)q85jZEtC}yZa!7L3HZ=5fq(Tu{2kDcJu{F@ zjbRS34`{4~N!lh>Sx8-ahg08m+ADB!m`;Q|D9DwWq+w#>yXJT45%~7Xi~w*#kG`hJ zOC=J?kCwLV)Zp{Q!UP29!+5b?$MHhCW)sGeIFfwb4;c*ZK4Y*B&I;fL4mprdLAYyfrkm4pmGl z&9;H8|En-O=UD~w?ztkC9pOJbhwzQXg2Mu?g*hQ80sgyL_XFSTm3lIO5qX3eqJKW` HUhn<|dxi~j literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.2.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Invoice.upcoming.2.json new file mode 100644 index 0000000000000000000000000000000000000000..0dede69d4fd08f59b5e0c470b494b0d864ff3faa GIT binary patch literal 2857 zcma)8ZI9zL5dOZuBCSCj9>E7 zb{D=S9?$rhc^;4F=_bnvYn79h){c{JvSpFy`B$Umj)@x9Cu^FwOh_SjQ-`i=M8&L7 zl5RN$ldfq(ENgk&Sz6&qL$t8UG5(e{hWovxXqph3RC}g(oHA!s3vnyfG$%6NL^Wqd zN$@AGt5l1A-X1*15GtoNm(|JdHFezP420$y7b|Dzua9qk`TpmhKK$?iRhWl8HM5w@ ze6@z!+%1ZwKcMDY<{C?la=M!2T60rr(P0@dYz!hy%KZt73sr~T&hH5S0}pDu1;13f zuou#_zD)DgVpA;UoAn$~1mlp{#Hn`LbAceXO7jDx**hg86_U0}+PyhH)3Z+UT-hIY z_nX195eMF?8dL5$^Eg^|1UhQu8B)K9*K*6Clnnfyo_idUwHS%qu0GG|RHNRi%D;Gp zdP&vlEggrdgJ?ssZdY%-K0OY^z*|}()02W&(Q@M<@-`H6)5klo#wTpG6Y$9fD_q+-b=g zCcOf~72OI6xqRX^Wq3@#9qtrIQlk7K6~9LnB@y;Agq?TG*b2PP@Pb_4plCYNe33cB zb@qqL^Lm|qaE<7)`$oAs`wd!$aBcPlv)N}w{wB|}S$5(~f7vSxAf%eHvO#qqDTyht z24$K?T)VCj&`T->_p3sL^?@=h6&292#+X2HLLtjTslX`^KflZGmbb+^^o9Tdj04rF zb;N2%S|ipD2t1F=Dhv1QB6kSNc00{?&JC#r?UVp@Sv$^4=1AD>c;~?f~o{ zkQQ}P*iou*NcBp?!C3`y z=K;J-FaUUgVz5Y2eM~)vN$KG9L0MoQMBrJO*gCCh7upei`rMYAK}?p zM~8C!?U=N}Vk<3%TAa5k{D0*xjvHIJRzSFU?e-?%W6uQs*(dR5KtuM-KruC@Il?}o zu@NR|n^4e7;zifB=0MFE*PvUP#xLVJwLw$=Aa`GH5j7_0l78Q0vP83*ivFXMXBRa>Gjx zy^O}@H63iCZRlO`nF?c%<`sw8hW7aSnBL*qg9HX>rI>AcB^1tEV@K;y#iZ738_4>< z3d4P#RdDa0D`MFZ{=;(!-*{PYSirR~Cj=$H|1jcmkowOS3JIrX_Kv8>jp4IBD9YYd7(< z)pi`)-}kwFyqZiH)U{RuP*sL+q~x`*rpW>h zj(dYj^TNx#z(Q`oYviu-G{2rlIZ@G>+(umwT2!Gs=KOl}W`(kJ6!1uZ5F`a4(9@6j zG)dOzIX9``q=V@eHFik~DJ4S6|M(O@N%m^}ON!7&DAEb5>PVVUS)5J^t2LOe&}0LF zY9FS8)<>LEPNLs-Yvq=(<=(+IAKWpdOygS;5XX9s#N nE+jMhAjOs>K@AMyA^SX-K99>dmDIe)+YOM6ZT4Wkdb;`t<^x%U literal 0 HcmV?d00001 diff --git a/corporate/tests/stripe_fixtures/attach_discount_to_realm:Token.create.1.json b/corporate/tests/stripe_fixtures/attach_discount_to_realm:Token.create.1.json new file mode 100644 index 0000000000000000000000000000000000000000..886506584a67f6fea201fb99169c6e0df76df6a0 GIT binary patch literal 826 zcmaJe?5488L!s+`dTZKqAUA#I0A`_d3Q>{6M;T|L^gN>a3f`0tAYWvoJ^m(+fK zelPZR6h%UUQQ|Jz`n&%Fr3_k|NphW!iZ_sylN94Yx^A^I0kP2JP(^bG4($+ElEx|X zEVM!sxdJ1LFg^>*WPx(U;8uq#s&ly5BXnDq14WkmpHFS5Vb+AtkkRKZ^j#Xz{5ax+ zEcB)F#QXdhT+0hQs?$)B%u28>{Vx)Knyjj|D||RPc;Z-xV0UY);I3YwrVTi%b>{hsnl{dxsXAxlE-vi-;=SK$k! z?8c9n3#Qj;65mXc+n9O9-k9gU>`Roi#;R5 None: + @mock_stripe("Customer.save", "Customer.retrieve", "Customer.create", "Invoice.upcoming", + "Token.create", "Charge.list", "Subscription.create") + def test_attach_discount_to_realm(self, mock7: Mock, mock6: Mock, mock5: Mock, mock4: Mock, + mock3: Mock, mock2: Mock, mock1: Mock) -> None: + # Attach discount before Stripe customer exists user = self.example_user('hamlet') - # Before customer exists attach_discount_to_realm(user, 85) - mock_create_customer.assert_called_once_with( - description=Kandra(), email=self.example_email('hamlet'), metadata=Kandra(), - source=None, coupon=self.stripe_coupon_id) - mock_create_customer.reset_mock() - # For existing customer - Coupon.objects.create(percent_off=42, stripe_coupon_id='42OFF') - with patch.object( - stripe.Customer, 'save', autospec=True, - side_effect=lambda stripe_customer: self.assertEqual(stripe_customer.coupon, '42OFF')): - attach_discount_to_realm(user, 42) - mock_create_customer.assert_not_called() + self.login(user.email) + response = self.client_get("/upgrade/") + self.client_post("/upgrade/", {'stripeToken': stripe_create_token().id, + 'signed_seat_count': self.get_signed_seat_count_from_response(response), + 'salt': self.get_salt_from_response(response), + 'plan': Plan.CLOUD_ANNUAL, + 'billing_modality': 'charge_automatically'}) + stripe_customer = stripe_get_customer(Customer.objects.get(realm=user.realm).stripe_customer_id) + assert(stripe_customer.discount is not None) # for mypy + self.assertEqual(stripe_customer.discount.coupon.percent_off, 85.0) + # Check that the customer was charged the discounted amount + charges = stripe.Charge.list(customer=stripe_customer.id) + for charge in charges: + self.assertEqual(charge.amount, get_seat_count(user.realm) * 80 * 15) + # Check upcoming invoice reflects the discount + upcoming_invoice = stripe.Invoice.upcoming(customer=stripe_customer.id) + self.assertEqual(upcoming_invoice.amount_due, get_seat_count(user.realm) * 80 * 15) + + # Attach discount to existing Stripe customer + attach_discount_to_realm(user, 25) + # Check upcoming invoice reflects the new discount + upcoming_invoice = stripe.Invoice.upcoming(customer=stripe_customer.id) + self.assertEqual(upcoming_invoice.amount_due, get_seat_count(user.realm) * 80 * 75) @patch("stripe.Subscription.delete") @patch("stripe.Customer.save") diff --git a/stubs/stripe/__init__.pyi b/stubs/stripe/__init__.pyi index 8be2b715d9..d603eef828 100644 --- a/stubs/stripe/__init__.pyi +++ b/stubs/stripe/__init__.pyi @@ -124,3 +124,10 @@ class Token: @staticmethod def create(card: Dict[str, Any]) -> Token: ... + +class Charge: + amount: int + + @staticmethod + def list(customer: Optional[str]) -> List[Charge]: + ...