def test_register_blueprint(self):
     app, registry = self._create_app()
     bp = self._create_blueprint(app)
     self._create_register(registry.register, app, bp)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}', '/holyHandGrenade.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     # FIXME this is broken urls shouldn't be added multiple times
     self.assertEqual([x.endpoint for x in app.url_map.iter_rules()],
                      ['holyHandGrenade',
                       'resources',
                       'cheese',
                       'blueish.get_a_holy_hand_grenade',
                       'blueish.toss_the_grenade',
                       'blueish.get_cheese',
                       'static'])
Exemple #2
0
 def test_register(self):
     app, registry = self._create_app()
     self._create_register(registry.register, app)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}', '/holyHandGrenade.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     self.assertEqual([x.endpoint for x in app.url_map.iter_rules()], [
         'holyHandGrenade', 'resources', 'cheese',
         'get_a_holy_hand_grenade', 'toss_the_grenade', 'get_cheese',
         'static'
     ])
     self.assertEqual([x.rule for x in app.url_map.iter_rules()], [
         '/api/v1/holyHandGrenade.json', '/api/v1/resources.json',
         '/api/v1/cheese.json', '/api/v1/holyHandGrenade/<number>',
         '/api/v1/holyHandGrenade/<number>', '/api/v1/cheese/<cheeseName>',
         '/static/<path:filename>'
     ])
 def test_register(self):
     app, registry = self._create_app()
     self._create_register(registry.register, app)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}', '/holyHandGrenade.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     self.assertEqual([x.endpoint for x in app.url_map.iter_rules()],
                      ['holyHandGrenade',
                       'resources',
                       'cheese',
                       'get_a_holy_hand_grenade',
                       'toss_the_grenade',
                       'get_cheese',
                       'static'])
     self.assertEqual([x.rule for x in app.url_map.iter_rules()],
                      ['/api/v1/holyHandGrenade.json',
                       '/api/v1/resources.json', '/api/v1/cheese.json',
                       '/api/v1/holyHandGrenade/<number>',
                       '/api/v1/holyHandGrenade/<number>',
                       '/api/v1/cheese/<cheeseName>',
                       '/static/<path:filename>'])
Exemple #4
0
 def test_add_register(self):
     app, registry = self._create_app()
     self._create_add_register(registry.add_register, app)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
 def test_add_register(self):
     app, registry = self._create_app()
     self._create_add_register(registry.add_register, app)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
Exemple #6
0
 def test_add_register_blueprint(self):
     app, registry = self._create_app()
     bp = self._create_blueprint(app)
     self._create_add_register(registry.add_register, app, bp)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     self.assertEqual(
         [x.endpoint for x in app.url_map.iter_rules()],
         ['resources', 'cheese', 'blueish.get_cheese', 'static'])
 def test_add_register_blueprint(self):
     app, registry = self._create_app()
     bp = self._create_blueprint(app)
     self._create_add_register(registry.add_register, app, bp)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     self.assertEqual([x.endpoint for x in app.url_map.iter_rules()],
                      ['resources',
                       'cheese',
                       'blueish.get_cheese',
                       'static'])
Exemple #8
0
 def test_register_blueprint(self):
     app, registry = self._create_app()
     bp = self._create_blueprint(app)
     self._create_register(registry.register, app, bp)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(sorted([x["path"] for x in data['apis']]),
                      ['/cheese.{format}', '/holyHandGrenade.{format}'])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {})
     # test cheese
     ret = app.test_client().get("/api/v1/cheese.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data["resourcePath"], "cheese")
     # FIXME this is broken urls shouldn't be added multiple times
     self.assertEqual([x.endpoint for x in app.url_map.iter_rules()], [
         'holyHandGrenade', 'resources', 'cheese',
         'blueish.get_a_holy_hand_grenade', 'blueish.toss_the_grenade',
         'blueish.get_cheese', 'static'
     ])
 def test_model(self):
     app, registry = self._create_app()
     self._create_model(registry.registerModel)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(data['apis'], [])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(data['models'], {'SomeCrazyClass': {
         'description': 'This is just the most crazy class!',
         'id': 'SomeCrazyClass',
         'required': ['name', 'age'], 'type': 'object',
         'properties': {'birthday': {'default': 'tomorrow'}}}})
Exemple #10
0
 def test_model(self):
     app, registry = self._create_app()
     self._create_model(registry.registerModel)
     ret = app.test_client().get("/api/v1/resources.json")
     data = json.loads(s(ret.data))
     self.assertEqual(data['swaggerVersion'], '1.3')
     self.assertEqual(data['basePath'], 'http://localhost:5000/api/v1')
     self.assertEqual(data['apis'], [])
     self.assertEqual(data['apiVersion'], '1.0')
     self.assertEqual(
         data['models'], {
             'SomeCrazyClass': {
                 'description': 'This is just the most crazy class!',
                 'id': 'SomeCrazyClass',
                 'required': ['name', 'age'],
                 'type': 'object',
                 'properties': {
                     'birthday': {
                         'default': 'tomorrow'
                     }
                 }
             }
         })