예제 #1
0
    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
        })
예제 #2
0
    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
        })
예제 #3
0
    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))
예제 #4
0
 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
     })
예제 #5
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))
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
파일: request.py 프로젝트: chaharv/privapi
 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)