Browse Source

[search] Add a MockResource.invoke and head method

This fixes the search.tests.TestWithMockedSolr tests
Erick Tryzelaar 10 years ago
parent
commit
e152be9
1 changed files with 11 additions and 0 deletions
  1. 11 0
      apps/search/src/search/tests.py

+ 11 - 0
apps/search/src/search/tests.py

@@ -52,6 +52,17 @@ class MockResource():
   def set_solr_response(cls, response):
   def set_solr_response(cls, response):
     MockResource.RESPONSE = response
     MockResource.RESPONSE = response
 
 
+  def invoke(self, method, *args, **kwargs):
+    if method.lower() == 'head':
+      return self.head(*args, **kwargs)
+    elif method.lower() == 'get':
+      return self.get(*args, **kwargs)
+    else:
+      raise Exception('do not know how to handle %s' % method)
+
+  def head(self, *args, **kwargs):
+    return ''
+
   def get(self, *args, **kwargs):
   def get(self, *args, **kwargs):
     if 'collection_1/admin/file' in args[0]:
     if 'collection_1/admin/file' in args[0]:
       return SOLR_SCHEMA
       return SOLR_SCHEMA