From d50c3cd98d6e99c7311286559136dc1a775a326d Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 02 Nov 2009 19:23:15 +0000 Subject: final version of the StoreProxy and its tests --- (limited to 'tutorius/store.py') diff --git a/tutorius/store.py b/tutorius/store.py index c197c9e..81925ed 100644 --- a/tutorius/store.py +++ b/tutorius/store.py @@ -27,10 +27,10 @@ class StoreProxy(object): shop to implement all the requests that could be made to the Store. """ - def __init__(self): + def __init__(self, base_url): # Base Urls for the api - self.base_url = "http://bobthebuilder.mine.nu/tutorius/en-US/tutorius" + self.base_url = base_url self.remora_api = "api/1.4" self.tutorius_api = "TutoriusApi" self.bandwagon_api = "api/1.4/sharing" @@ -50,14 +50,13 @@ class StoreProxy(object): @return The list of category names stored on the server. """ - categories = {} request_url = "/%s/categories" % (self.tutorius_api) response = self.conn.request_get(request_url) if self.helper.iserror(response): - return categories + return None xml_response = minidom.parseString(response['body']) @@ -92,7 +91,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -123,7 +122,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -150,7 +149,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -184,6 +183,9 @@ class StoreProxy(object): response = self.conn.request_get(request_url) + if (self.helper.iserror(response)): + return None + xml = minidom.parseString(response['body']) versionnode = xml.getElementsByTagName("version")[0] @@ -211,7 +213,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml = minidom.parseString(response['body']) @@ -267,7 +269,7 @@ class StoreProxy(object): if (self.helper.iserror(response)): return False - self.api_auth_key = "" + self.api_auth_key = None return True @@ -316,10 +318,11 @@ class StoreProxy(object): """ # This is in the case we have to re-publish a tutorial - if tutorial_store_id != None: + if tutorial_store_id is not None: request_url = "/%s/publish/%s" % (self.tutorius_api, tutorial_store_id) + headers = { 'X-API-Auth' : self.api_auth_key } - response = self.conn.request_post(request_url) + response = self.conn.request_post(request_url, None, None, None, headers) if self.helper.iserror(response): return False -- cgit v0.9.1