Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-hanna committed Aug 18, 2018
1 parent 5c31c61 commit beff182
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ notes.txt
node/test_data/go_example_image.tar

coverage.out

__pycache__
Binary file removed __pycache__/sdk.cpython-35.pyc
Binary file not shown.
43 changes: 43 additions & 0 deletions sdk_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ctypes import *
import unittest
import sdk
import json

hexutil = CDLL('./lib/hexutil/hexutil.so')

Expand Down Expand Up @@ -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()

0 comments on commit beff182

Please sign in to comment.