Add debug / test mechanism

This commit is contained in:
AKFish
2013-08-21 19:25:05 +08:00
parent 912bec79d2
commit 1d18ea75cc
2 changed files with 74 additions and 0 deletions
+11
View File
@@ -39,6 +39,12 @@ class GithubObject(object):
"""
Base class for all classes representing objects returned by the API.
"""
'''
A global debug flag to enable header validation by requester for all objects
'''
CHECK_AFTER_INIT_FLAG = False
def __init__(self, requester, headers, attributes, completed):
self._requester = requester
# Make sure headers are signed before any operations on attributes
@@ -47,6 +53,11 @@ class GithubObject(object):
self._initAttributes()
self._storeAndUseAttributes(attributes)
# Ask requester to do some checking, for debug and test purpose
# Since it's most handy to access and kinda all-knowing
if (GithubObject.CHECK_AFTER_INIT_FLAG):
requester.check_me(self);
def _storeAndUseAttributes(self, attributes):
self._useAttributes(attributes)
self._rawData = attributes