comment out unused part of code in tests

This commit is contained in:
Mateusz Sikora 2014-10-08 12:26:32 +02:00
parent 4088081707
commit 489bac6e1f

View File

@ -26,16 +26,16 @@ class APIClient(Client):
return self.generic('OPTIONS', path, data, content_type, **extra) return self.generic('OPTIONS', path, data, content_type, **extra)
class CustomJSONEncoder(json.JSONEncoder): # class CustomJSONEncoder(json.JSONEncoder):
""" # """
Convert datetime/date objects into isoformat # Convert datetime/date objects into isoformat
""" # """
def default(self, obj): # def default(self, obj):
if isinstance(obj, (datetime, date, time)): # if isinstance(obj, (datetime, date, time)):
return obj.isoformat() # return obj.isoformat()
else: # else:
return super(CustomJSONEncoder, self).default(obj) # return super(CustomJSONEncoder, self).default(obj)
class BaseAPITestCase(object): class BaseAPITestCase(object):
@ -52,7 +52,7 @@ class BaseAPITestCase(object):
kwargs['content_type'] = 'application/json' kwargs['content_type'] = 'application/json'
if 'data' in kwargs and request_method != 'get' and kwargs['content_type'] == 'application/json': if 'data' in kwargs and request_method != 'get' and kwargs['content_type'] == 'application/json':
data = kwargs.get('data', '') data = kwargs.get('data', '')
kwargs['data'] = json.dumps(data, cls=CustomJSONEncoder) kwargs['data'] = json.dumps(data) # , cls=CustomJSONEncoder
if 'status_code' in kwargs: if 'status_code' in kwargs:
status_code = kwargs.pop('status_code') status_code = kwargs.pop('status_code')
@ -60,10 +60,6 @@ class BaseAPITestCase(object):
if hasattr(self, 'token'): if hasattr(self, 'token'):
kwargs['HTTP_AUTHORIZATION'] = 'Token %s' % self.token kwargs['HTTP_AUTHORIZATION'] = 'Token %s' % self.token
if hasattr(self, 'company_token'):
kwargs[
'HTTP_AUTHORIZATION'] = 'Company-Token %s' % self.company_token
self.response = request_func(*args, **kwargs) self.response = request_func(*args, **kwargs)
is_json = bool( is_json = bool(
filter(lambda x: 'json' in x, self.response._headers['content-type'])) filter(lambda x: 'json' in x, self.response._headers['content-type']))
@ -84,28 +80,28 @@ class BaseAPITestCase(object):
def patch(self, *args, **kwargs): def patch(self, *args, **kwargs):
return self.send_request('patch', *args, **kwargs) return self.send_request('patch', *args, **kwargs)
def put(self, *args, **kwargs): # def put(self, *args, **kwargs):
return self.send_request('put', *args, **kwargs) # return self.send_request('put', *args, **kwargs)
def delete(self, *args, **kwargs): # def delete(self, *args, **kwargs):
return self.send_request('delete', *args, **kwargs) # return self.send_request('delete', *args, **kwargs)
def options(self, *args, **kwargs): # def options(self, *args, **kwargs):
return self.send_request('options', *args, **kwargs) # return self.send_request('options', *args, **kwargs)
def post_file(self, *args, **kwargs): # def post_file(self, *args, **kwargs):
kwargs['content_type'] = MULTIPART_CONTENT # kwargs['content_type'] = MULTIPART_CONTENT
return self.send_request('post', *args, **kwargs) # return self.send_request('post', *args, **kwargs)
def get_file(self, *args, **kwargs): # def get_file(self, *args, **kwargs):
content_type = None # content_type = None
if 'content_type' in kwargs: # if 'content_type' in kwargs:
content_type = kwargs.pop('content_type') # content_type = kwargs.pop('content_type')
response = self.send_request('get', *args, **kwargs) # response = self.send_request('get', *args, **kwargs)
if content_type: # if content_type:
self.assertEqual( # self.assertEqual(
bool(filter(lambda x: content_type in x, response._headers['content-type'])), True) # bool(filter(lambda x: content_type in x, response._headers['content-type'])), True)
return response # return response
def init(self): def init(self):
settings.DEBUG = True settings.DEBUG = True