def test_count(self): s = Scanner(app) co = CountObject() s.scan(route=[co]) self.assertEqual(co.long_name, 'createUsersWithArrayInput') self.assertEqual(co.total, { Authorization: 1, Resource: 3, Operation: 20 })
def test_count(self): s = Scanner(app) co = CountObject() s.scan(route=[co], root=app.raw) self.assertEqual(co.long_name, 'createUsersWithArrayInput') self.assertEqual(co.total, { Authorization: 1, Resource: 3, Operation: 20 })
def test_load(self): """ make sure the result of yaml and json are identical """ app_json = App.load( get_test_data_folder(version='2.0', which='wordnik')) app_yaml = App.load(get_test_data_folder( version='2.0', which='yaml', )) s = Scanner(app_yaml) s.scan(route=[YamlFixer()], root=app_yaml.raw, leaves=[Operation]) self.assertEqual((True, ''), app_json.raw.compare(app_yaml.raw))
def test_leaves(self): s = Scanner(app) co = CountObject() s.scan(route=[co], root=app.raw, leaves=[Operation]) # the scanning would stop at Operation, so ResponseMessage # would not be counted. self.assertEqual(co.total, { Authorization: 1, Resource: 3, Operation: 20, ResponseMessage: 0 })
def test_load(self): """ make sure the result of yaml and json are identical """ app_json = SwaggerApp.load(get_test_data_folder( version='2.0', which='wordnik' )) app_yaml = SwaggerApp.load(get_test_data_folder( version='2.0', which='yaml', ) ) s = Scanner(app_yaml) s.scan(route=[YamlFixer()], root=app_yaml.raw, leaves=[Operation]) self.assertEqual((True, ''), app_json.raw.compare(app_yaml.raw))
def test_path(self): self.maxDiff = None s = Scanner(app) p = PathRecord() s.scan(route=[p], root=app.raw) self.assertEqual(sorted(p.resource), sorted(['#/apis/store', '#/apis/user', '#/apis/pet'])) self.assertEqual(p.authorization, ['#/authorizations/oauth2']) self.assertEqual(sorted(p.response_message), sorted([ '#/apis/store/apis/placeOrder/responseMessages/0', '#/apis/store/apis/deleteOrder/responseMessages/1', '#/apis/store/apis/deleteOrder/responseMessages/0', '#/apis/store/apis/getOrderById/responseMessages/1', '#/apis/store/apis/getOrderById/responseMessages/0' ])) self.assertEqual(len(p.parameter), 3)
def _api_to_requests(self, fname, org): self.app = App.create(fname) self.org = org s = Scanner(self.app) s.scan(route=[self], root=self.app.raw)