Example #1
0
    def test_version_v1_multiple_path(self):
        req = webob.Request.blank('/v1')
        req.accept = "application/json"
        res = req.get_response(fake_wsgi.wsgi_app())
        self.assertEqual(httplib.OK, res.status_int)
        self.assertEqual("application/json", res.content_type)

        req_ = webob.Request.blank('/v1/')
        req_.accept = "application/json"
        res_ = req_.get_response(fake_wsgi.wsgi_app())
        self.assertEqual(httplib.OK, res_.status_int)
        self.assertEqual("application/json", res_.content_type)

        self.assertEqual(json.loads(res.body), json.loads(res_.body))
Example #2
0
    def test_version_v1_multiple_path(self):
        req = webob.Request.blank('/v1')
        req.accept = "application/json"
        res = req.get_response(fake_wsgi.wsgi_app())
        self.assertEqual(http_client.OK, res.status_int)
        self.assertEqual("application/json", res.content_type)

        req_ = webob.Request.blank('/v1/')
        req_.accept = "application/json"
        res_ = req_.get_response(fake_wsgi.wsgi_app())
        self.assertEqual(http_client.OK, res_.status_int)
        self.assertEqual("application/json", res_.content_type)

        self.assertEqual(json.loads(res.body.decode('utf-8')),
                         json.loads(res_.body.decode('utf-8')))
Example #3
0
 def test_version_v1_show(self):
     req = webob.Request.blank('/v1')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(http_client.OK, res.status_int)
     self.assertEqual("application/json", res.content_type)
     versions = json.loads(res.body.decode('utf-8'))
     expected = {
         "version": {
             "status":
             "CURRENT",
             "updated":
             "2013-08-12T17:42:13Z",
             "id":
             "v1",
             "links": [{
                 "href": "http://localhost/v1/",
                 "rel": "self"
             }, {
                 "rel": "describedby",
                 "type": "text/html",
                 "href": "http://congress.readthedocs.org/",
             }]
         }
     }
     self.assertEqual(expected, versions)
Example #4
0
 def test_versions_choices(self):
     req = webob.Request.blank('/fake')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(httplib.MULTIPLE_CHOICES, res.status_int)
     self.assertEqual("application/json", res.content_type)
     versions = json.loads(res.body)
     expected = {
         "choices": [{
             "status": "CURRENT",
             "updated": "2013-08-12T17:42:13Z",
             "id": "v1",
             "links": [{
                 "href": "http://localhost/v1/fake",
                 "rel": "self"
             }]
         }]
     }
     self.assertEqual(expected, versions)
Example #5
0
 def test_versions_list(self):
     req = webob.Request.blank('/')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(http_client.OK, res.status_int)
     self.assertEqual("application/json", res.content_type)
     versions = json.loads(res.body.decode('utf-8'))
     expected = {
         "versions": [{
             "status": "CURRENT",
             "updated": "2013-08-12T17:42:13Z",
             "id": "v1",
             "links": [{
                 "href": "http://localhost/v1/",
                 "rel": "self"
             }]
         }]
     }
     self.assertEqual(expected, versions)
Example #6
0
 def test_versions_choices(self):
     req = webob.Request.blank('/fake')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(http_client.MULTIPLE_CHOICES, res.status_int)
     self.assertEqual("application/json", res.content_type)
     versions = json.loads(res.body.decode('utf-8'))
     expected = {
         "choices": [{
             "status":
             "CURRENT",
             "updated":
             "2013-08-12T17:42:13Z",
             "id":
             "v1",
             "links": [{
                 "href": "http://localhost/v1/fake",
                 "rel": "self"
             }]
         }]
     }
     self.assertEqual(expected, versions)
Example #7
0
 def test_version_v1_show(self):
     req = webob.Request.blank('/v1')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(httplib.OK, res.status_int)
     self.assertEqual("application/json", res.content_type)
     versions = json.loads(res.body)
     expected = {
         "version": {
             "status": "CURRENT",
             "updated": "2013-08-12T17:42:13Z",
             "id": "v1",
             "links": [{
                 "href": "http://localhost/v1/",
                 "rel": "self"
             }, {
                 "rel": "describedby",
                 "type": "text/html",
                 "href": "http://congress.readthedocs.org/",
             }]
         }
     }
     self.assertEqual(expected, versions)
Example #8
0
 def test_version_v1_not_found(self):
     req = webob.Request.blank('/v1/fake')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(httplib.NOT_FOUND, res.status_int)
     self.assertEqual("application/json", res.content_type)
Example #9
0
 def test_version_v1_not_found(self):
     req = webob.Request.blank('/v1/fake')
     req.accept = "application/json"
     res = req.get_response(fake_wsgi.wsgi_app())
     self.assertEqual(http_client.NOT_FOUND, res.status_int)
     self.assertEqual("application/json", res.content_type)