Skip to content

Commit

Permalink
[test] add test case for dumping float
Browse files Browse the repository at this point in the history
- #92
  • Loading branch information
mission-liao committed Jan 9, 2017
1 parent 251a1d1 commit 6fe0b0b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
24 changes: 24 additions & 0 deletions pyswagger/tests/data/v2_0/schema/floatDump/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"swagger":"2.0",
"host":"http://test.com",
"basePath":"/v1",
"definitions":{
"Location":{
"title":"Location",
"type":"object",
"properties":{
"lon":{
"type":"number",
"example":86.12,
"description":"Longitude"
},
"lat":{
"type":"number",
"example":56.123,
"description":"Latitude"
}
},
"required":["lon", "lat"]
}
}
}
12 changes: 10 additions & 2 deletions pyswagger/tests/v2_0/test_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_model_bool(self):
""" test a model containing boolean """
d = self.app.resolve("#/definitions/model_bool")

dv = d._prim_(dict(bool_val=True), self.app.prim_factory)
dv = d._prim_(dict(bool_val=True), self.app.prim_factory)
# try to access it
self.assertEqual(dv.bool_val, True)

Expand Down Expand Up @@ -213,6 +213,14 @@ def test_read_only(self):
resp = io.Response(op)
resp.apply_with(0, '{"protected":1}') # allowed

def test_float_dump(self):
""" failed to dump an object with float property
refer to issue: https://github.com/mission-liao/pyswagger/issues/92
"""
app = App.create(get_test_data_folder(version='2.0', which=os.path.join('schema', 'floatDump')))
app.dump() # should not raise exception


class HeaderTestCase(unittest.TestCase):
""" test for Header object """
Expand Down Expand Up @@ -413,7 +421,7 @@ def setUpClass(kls):

def test_unknown(self):
p = self.app.resolve('#/paths/~1t/put')
self.assertRaises(ValueError, p, p1='tom', p2='mary', p3='qoo', p4='unknown')
self.assertRaises(ValueError, p, p1='tom', p2='mary', p3='qoo', p4='unknown')


class PrimitiveExtensionTestCase(unittest.TestCase):
Expand Down

0 comments on commit 6fe0b0b

Please sign in to comment.