From beff182ded1581cd38033ee2363a6bd75e6d39ef Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 17 Aug 2018 22:13:17 -0700 Subject: [PATCH] all tests passing --- .gitignore | 2 ++ __pycache__/sdk.cpython-35.pyc | Bin 5876 -> 0 bytes sdk_test.py | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) delete mode 100644 __pycache__/sdk.cpython-35.pyc diff --git a/.gitignore b/.gitignore index 9399618..f1e1d94 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ notes.txt node/test_data/go_example_image.tar coverage.out + +__pycache__ diff --git a/__pycache__/sdk.cpython-35.pyc b/__pycache__/sdk.cpython-35.pyc deleted file mode 100644 index 630eb525ed39e4dfb793e98785116757f9832728..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5876 zcmcgw&349U1{%fbD_%-or8X0SLl zRsCo0(Z}!16a9-$T^{J`xU&UC6ysk}hiHo_hdPS74h0S=es-zjQrDxvE1o^-lqe|4 zD$qU!KIt;WC3>PLm=M|*x*~L0=&H~YLQm2=afRY4eU9xhP@^X<1yiK)KS}LrYR(8< zq4uoM=O~_(m2;#)V?N$=Ug#;I=dt57#WS+w3_St&3#1oGSE>CJJt3adUZVCg#j{Mu z*kz7B$1WGJ@;t@!vT|NlK25PloAre+SzmQ!)k|nf@Aq|IgYdWZj1J?*U}<%&)7oC! z3$wjevOD@+&C-(*eb~=iowdE_uzS+2VosLNTrf4O&*@1@Ba$kpDFDPfx_ zmdry_b1F)D2FqQIS@BBPVZ|S<7`@xVE=I?Lh2c<~>TD%R^A&xFp~17mZle$SErX%_ zQMwYE-F{amdG-};I(XG}ekXKzR-4cxEHrRggD?rEJ+|}M7a9c2enM!UPAob==Oh~` z&!3=pieQ>d!{ldh60_D>zZ&s-`Ql$b(RJL}6*MiP$3)E&LQyV93uc~>;vttFE13gk z2phT$TkeL3S!^Sw1ywe1^c-U){)yU?wC|J2DX-D56#bTH z2d)5Rx%3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}eHwSRgyyRVJf&PUjfjLJt>8!tdx=H}%)jgv;tAgaad=6LdW66Q z>cT4&(lKN|IBj*{4sBI6V0U-0$jqa$?yk;*N*-qW%{Wa^w24igVb%H_t|F2?R%Gmh z1pXEa-inckJNaTSo!4tcxb=%#F{o~8^H7^xDSS@Ol=GBP@4eLI)-Prh zBC|RSvyNn=4{U_TnjE#Dw}%a^*OLXAY-#;Rso96AodLa)3=gnJRz*Wz{&@9Vhp{Tb*EwO zV|BfFOTja%tzh>99&+szw3q9*5i#zC`JQ#6t0v$%V?iWMD>d|^^{by_WT>#3Q-!*! zj`=0}BHSkz8~k=|V*dEz-xJSaw}(W~0qhh)GJ!_~3=jwl zjO_3h*D%_e54m9*8N&9N-ZPTPq5cuGhwj1^;b5jPw{cB~ak;o2g>g51=R`k&NVGo&CJof&;?e%lXhVbF0lV-Z^ z1|Gm9v0fbJVc_Q7-kEc@lY3zj;~Nl9`wNRvq|-hC5~(yPbh{7`tYm0Z5w;p_w!kvWOie}o^i zjV73kIxXb4O=cu0hjEM|EeocHy@hyZG1B}TEB}Oh81|IjvR@E&2 UpaB;*|2d03w*`H^{o>?*04I30`~Uy| diff --git a/sdk_test.py b/sdk_test.py index 243a0a2..b976473 100644 --- a/sdk_test.py +++ b/sdk_test.py @@ -1,6 +1,7 @@ from ctypes import * import unittest import sdk +import json hexutil = CDLL('./lib/hexutil/hexutil.so') @@ -30,5 +31,47 @@ def setStuff(k, v): self.assertEqual(expectKey, key) self.assertEqual(expectVal, val) + def test_store(self): + key = "foo" + val = "bar" + + c3.state[key] = val + + self.assertEqual(c3.state[key], val) + del c3.state[key] + + def test_state(self): + methodName = "setState" + + key1 = "foo" + val1 = "bar" + + key2 = "foofoo" + val2 = "barbar" + + def setState(k, v): + c3.state[k] = v + + c3.registerMethod(methodName, setState) + + p1 = [ + methodName, + c_char_p(hexutil.EncodeString(c_char_p(key1.encode('utf-8')))).value.decode('utf-8'), + c_char_p(hexutil.EncodeString(c_char_p(val1.encode('utf-8')))).value.decode('utf-8'), + ] + p2 = [ + methodName, + c_char_p(hexutil.EncodeString(c_char_p(key2.encode('utf-8')))).value.decode('utf-8'), + c_char_p(hexutil.EncodeString(c_char_p(val2.encode('utf-8')))).value.decode('utf-8'), + ] + + params = [p1, p2] + paramsJSON = json.dumps(params) + + c3.process(paramsJSON) + + self.assertEqual(c3.state[key1], val1) + self.assertEqual(c3.state[key2], val2) + if __name__ == '__main__': unittest.main()