def test_configure(): """ This is a basic test to make sure that the configuration mechanism works. """ default_configs = sdk.config.configure() configs = {"api_key": "TESTKEY", "api_version": 31337, "base_url": "example.com"} sdk.configure(**configs) for key in configs.iterkeys(): assert configs[key] == sdk.config._configuration[key] sdk.configure(**default_configs)
# To handle package name changes curdir = os.path.dirname(os.path.realpath(__file__)) setup_file = imp.load_source( 'setup', os.path.join(curdir, '..', '..', '..', 'setup.py')) sys.modules['sdk'] = __import__(setup_file.package_name) import dynamic_case_module import sdk API_KEY = os.environ.get('API_KEY') DEV_KEY = os.environ.get('DEV_KEY') BASE_URL = os.environ.get('BASE_URL') if not BASE_URL: BASE_URL = 'https://api.kloudless.com' sdk.configure(api_key=API_KEY, dev_key=DEV_KEY, base_url=BASE_URL) sdk.BaseResource._api_session = requests.Session() def create_or_get_test_folder(account, parent_id='root', name=None): test_folders = dynamic_case_module.test_folders if account.id in test_folders: return test_folders[account.id] if not name: name = u't\xe9st folder %s' % random.randint(0, 10e8) folder = account.folders.retrieve(id=parent_id) # Find the first folder that supports folder creation within it and # create the test folder in it.
def wrapper(*args, **kwargs): default_config = sdk.config.configure() sdk.configure(**test_configuration) result = f(*args, **kwargs) sdk.configure(**default_config) return result