def test_wrong_param(self): client = configcatclient.create_client_with_auto_poll( _SDK_KEY, poll_interval_seconds=0, max_init_wait_time_seconds=-1) time.sleep(2) self.assertEqual('This text came from ConfigCat', client.get_value('keySampleText', 'default value')) client.stop()
def test_client_works_invalid_proxy(self): proxies = {'https': '0.0.0.0:0'} proxy_auth = HTTPProxyAuth("test", "test") client = configcatclient.create_client_with_auto_poll( _SDK_KEY, proxies=proxies, proxy_auth=proxy_auth) self.assertEqual('default value', client.get_value('keySampleText', 'default value')) client.stop()
def test_force_refresh(self): client = configcatclient.create_client_with_auto_poll(_SDK_KEY) self.assertEqual('This text came from ConfigCat', client.get_value('keySampleText', 'default value')) client.force_refresh() self.assertEqual('This text came from ConfigCat', client.get_value('keySampleText', 'default value')) client.stop()
import configcatclient from PIL import Image, ImageOps from config import key import os configcat_client = configcatclient.create_client_with_auto_poll( key, poll_interval_seconds=1) while True: invert_dog = configcat_client.get_value('invert_dog', False) if invert_dog: im = Image.open('dog.jpg') # imports file im_invert = ImageOps.invert(im) # inverts image im_invert.save('inverted-dog.jpg', quality=95) # saves new file print('invert_dog\'s value: ' + str(invert_dog)) break else: try: os.remove('inverted-dog.jpg') # deletes created file print('invert_dog\'s value: ' + str(invert_dog)) break except os.error: pass print('invert_dog\'s value is still: ' + str(invert_dog)) break
def test_client_works_invalid_base_url(self): client = configcatclient.create_client_with_auto_poll( _SDK_KEY, base_url='https://invalidcdn.configcat.com') self.assertEqual('default value', client.get_value('keySampleText', 'default value')) client.stop()
def test_client_works_valid_base_url_trailing_slash(self): client = configcatclient.create_client_with_auto_poll( _SDK_KEY, base_url='https://cdn.configcat.com/') self.assertEqual('This text came from ConfigCat', client.get_value('keySampleText', 'default value')) client.stop()
def test_without_sdk_key(self): try: configcatclient.create_client_with_auto_poll(None) self.fail('Expected ConfigCatClientException') except ConfigCatClientException: pass
def test_client_works_request_timeout(self, mock_get): client = configcatclient.create_client_with_auto_poll(_SDK_KEY) self.assertEqual('default value', client.get_value('keySampleText', 'default value')) client.stop()