-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from mission-liao/op
Op
- Loading branch information
Showing
8 changed files
with
220 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"swagger":"2.0", | ||
"host":"http://test.com", | ||
"basePath":"/v1", | ||
"paths":{ | ||
"/a":{ | ||
"get":{ | ||
"operationId":"a.get", | ||
"responses":{ | ||
"default":{ | ||
"description":"void" | ||
} | ||
} | ||
}, | ||
"$ref":"#/paths/~1b" | ||
}, | ||
"/b":{ | ||
"get":{ | ||
"operationId":"b.get", | ||
"responses":{ | ||
"default":{ | ||
"description":"void" | ||
} | ||
} | ||
}, | ||
"$ref":"#/paths/~1c" | ||
}, | ||
"/c":{ | ||
"put":{ | ||
"operationId":"c.put", | ||
"responses":{ | ||
"default":{ | ||
"description":"void" | ||
} | ||
} | ||
}, | ||
"$ref":"#/paths/~1d" | ||
}, | ||
"/d":{ | ||
"post":{ | ||
"operationId":"d.post", | ||
"responses":{ | ||
"default":{ | ||
"description":"void" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pyswagger import SwaggerApp, utils | ||
from ..utils import get_test_data_folder | ||
import unittest | ||
|
||
def _check(u, op): | ||
u.assertEqual(op.operationId, 'addPet') | ||
|
||
class OperationAccessTestCase(unittest.TestCase): | ||
""" test for methods to access Operation """ | ||
|
||
@classmethod | ||
def setUpClass(kls): | ||
kls.app = SwaggerApp._create_(get_test_data_folder(version='2.0', which='wordnik')) | ||
|
||
def test_resolve(self): | ||
""" | ||
""" | ||
_check(self, self.app.resolve(utils.jp_compose(['#', 'paths', '/pet', 'post']))) | ||
|
||
def test_cascade_resolve(self): | ||
""" | ||
""" | ||
path = self.app.resolve(utils.jp_compose(['#', 'paths', '/pet'])) | ||
|
||
_check(self, path.resolve('post')) | ||
_check(self, path.post) | ||
|
||
def test_tag_operationId(self): | ||
""" | ||
""" | ||
_check(self, self.app.op['pet', 'addPet']) | ||
_check(self, self.app.op['addPet']) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pyswagger import SwaggerApp, utils | ||
from pyswagger.spec.v2_0 import objects | ||
from ..utils import get_test_data_folder | ||
import unittest | ||
import os | ||
|
||
|
||
class ResolvePathItemTestCase(unittest.TestCase): | ||
""" test for PathItem $ref """ | ||
|
||
@classmethod | ||
def setUpClass(kls): | ||
kls.app = SwaggerApp._create_(get_test_data_folder( | ||
version='2.0', | ||
which=os.path.join('resolve', 'path_item') | ||
)) | ||
|
||
def test_path_item(self): | ||
""" make sure PathItem is correctly merged """ | ||
a = self.app.resolve(utils.jp_compose('/a', '#/paths')) | ||
|
||
self.assertTrue(isinstance(a, objects.PathItem)) | ||
self.assertTrue(a.get.operationId, 'a.get') | ||
self.assertTrue(a.put.operationId, 'c.put') | ||
self.assertTrue(a.post.operationId, 'd.post') |