Skip to content

Instantly share code, notes, and snippets.

@moshez
Created May 19, 2013 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moshez/5609485 to your computer and use it in GitHub Desktop.
Save moshez/5609485 to your computer and use it in GitHub Desktop.
diff --git a/tests/ncolony/tests/nidl/test_interface.py b/tests/ncolony/tests/nidl/test_interface.py
index 85f7ffb..9ef57fa 100644
--- a/tests/ncolony/tests/nidl/test_interface.py
+++ b/tests/ncolony/tests/nidl/test_interface.py
@@ -104,6 +104,62 @@ class Foo(types.Implementation):
def remote_float(self, a):
return dict(b=1-a)
+class TestDocumentation(unittest.TestCase):
+
+ def test_documentFloat(self):
+ document = types.Float().document()
+ self.assertEquals(document, dict(type='float'))
+
+ def test_documentInt(self):
+ document = types.Int().document()
+ self.assertEquals(document, dict(type='int'))
+
+ def test_documentIntRange(self):
+ document = types.Int(min=0,max=10).document()
+ self.assertEquals(document, dict(type='int',min=0,max=10))
+
+ def test_documentString(self):
+ document = types.String(maxLen=10).document()
+ self.assertEquals(document, dict(type='string',maxLen=10))
+
+ def test_documentEnum(self):
+ document = types.Enum(YES="yeah",NO="nuh").document()
+ self.assertEquals(document, dict(type='enum',values=dict(YES="yeah",NO="nuh")))
+
+ def test_documentList(self):
+ document = types.List(types.Int(max=3),maxLen=5).document()
+ self.assertEquals(document, dict(type='list',maxLen=5,element=dict(type='int',min=0,max=10)))
+
+ def test_documentStruct(self):
+ document = BarStruct.document()
+ self.assertEquals(document, dict(type='struct',name='BarStruct',
+ fields=dict(value=dict(type='int'),
+ uuid=dict(type='string',maxLen=3))))
+
+ def test_documentFloatMethod(self):
+ documentation = IFoo.document()['float']
+ self.assertEquals(documentation['name'], 'float')
+ self.assertEquals(documentation['input'], dict(a=dict(type='float'))
+ self.assertEquals(documentation['output'], dict(b=dict(type='float'))
+
+ def test_documentListMethod(self):
+ documentation = IFoo.document()['list']
+ self.assertEquals(documentation['name'], 'list')
+ self.assertEquals(documentation['input'],
+ dict(a=dict(type='list',
+ maxLen=2,
+ element=dict(type='struct',
+ name='BarStruct',
+ fields=dict(uuid=dict(type='string',maxLen=3),
+ value=dict(type='int'))))))
+ self.assertEquals(documentation['output'],
+ dict(b=dict(type='list',
+ maxLen=1,
+ element=dict(type='struct',
+ name='BarStruct',
+ fields=dict(uuid=dict(type='string',maxLen=3),
+ value=dict(type='int'))))))
+
@mock.patch("ncolony.nidl.types.LOG")
class TestImplementation(unittest.TestCase):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment