Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure resource URLs have the correct path

Fix #40
  • Loading branch information...
commit 99ecc6cb51c9f2f6467e43a5cae7890be2996ec8 1 parent 3b117fe
Kyle Conroy kyleconroy authored
8 docs/_static/examples/example.py
View
@@ -5,13 +5,13 @@
import random
# Stashboard application id
-app_id = "stashboard"
+app_id = "stashboard-hrd"
# These keys can be found at /admin/credentials
consumer_key = 'anonymous'
consumer_secret = 'anonymous'
-oauth_key = 'ACCESS_TOKEN'
-oauth_secret = 'ACCESS_SECRET'
+oauth_key = '1/97AeXBu2IRJMOmG5c1km50Nb4_-OLZ0tU93T2G1Pay0'
+oauth_secret = 'QniHPrrux6EgV1_p6L6cAvs0'
# Create your consumer with the proper key/secret.
# If you register your application with google, these values won't be
@@ -62,4 +62,4 @@
})
resp, content = client.request(service["url"] + "/events", "POST", body=data)
-event = json.loads(content)
+print json.loads(content)
5 stashboard/handlers/restful.py
View
@@ -137,7 +137,10 @@ class ServiceListHandlerReadOnly(ReadOnlyHandler, cls):
def base_url(self, version):
"Returns the base url for the given host and version"
host = self.request.headers.get('host', 'nohost')
- return self.request.scheme + "://" + host + "/api/" + version
+ if "admin/api" in self.request.path:
+ return self.request.scheme + "://" + host + "/admin/api/" + version
+ else:
+ return self.request.scheme + "://" + host + "/api/" + version
def valid_version(self, version):
return version == "v1"
14 tests/test_rest_status.py
View
@@ -93,11 +93,25 @@ def test_get_status(self):
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
+ def test_url_api_correct(self):
+ response = self.get("/admin/api/v1/statuses/foo")
+ data = json.loads(response.content)
+ self.assertEquals(data['url'], 'http://localhost:80/admin/api/v1/statuses/foo')
+
+ def test_url_admin_api_correct(self):
+ response = self.get("/api/v1/statuses/foo")
+ data = json.loads(response.content)
+ self.assertEquals(data['url'], 'http://localhost:80/api/v1/statuses/foo')
+
def test_delete_success(self):
response = self.delete("/admin/api/v1/statuses/foo")
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
+ data = json.loads(response.content)
+
+ self.assertEquals(data['url'], 'http://localhost:80/admin/api/v1/statuses/foo')
+
status = Status.get(self.status.key())
self.assertEquals(status, None)
Please sign in to comment.
Something went wrong with that request. Please try again.