class MockAPI(API): api_key = 'abcdef' api_url = 'http://host' api_version = 'v1' etsy_oauth_client = EtsyOAuthClient('consumer_key', 'consumer_secret') def etsy_home(self): return Test.scratch_dir def get_method_table(self, *args): return [{ 'name': 'testMethod', 'uri': '/test/{test_id}', 'http_method': 'GET', 'params': { 'limit': 'int', 'test_id': 'user_id_or_name', 'offset': 'int', 'fizz': 'enum(foo, bar, baz)', 'buzz': 'float', 'blah': 'unknown type', 'kind': 'string', }, 'type': 'int', 'description': 'test method.' }, { 'name': 'noPositionals', 'uri': '/blah', 'http_method': 'GET', 'params': { 'foo': 'int' }, 'type': 'int', 'description': 'no pos arguments' }] def _get_url(self, url, http_method, content_type, body): return '{ "count": 1, "results": [3] }'
config_file.write("oauth_consumer_key = %r\n" % config.oauth_consumer_key) config_file.write("oauth_consumer_secret = %r\n" % config.oauth_consumer_secret) if oauth_token: config_file.write("oauth_token_key = %r\n" % oauth_token.key) config_file.write("oauth_token_secret = %r\n" % oauth_token.secret) try: import config except ImportError: config = None write_config_file(oauth_token=None) if hasattr(config, 'oauth_consumer_key') and hasattr(config, 'oauth_consumer_secret'): oauth_client = EtsyOAuthClient( oauth_consumer_key=config.oauth_consumer_key, oauth_consumer_secret=config.oauth_consumer_secret, etsy_env=etsy_env) else: sys.stderr.write('ERROR: You must set oauth_consumer_key and oauth_consumer_secret in config.py\n') sys.exit(1) if hasattr(config, 'oauth_token_key') and hasattr(config, 'oauth_token_secret'): oauth_client.token = oauth.Token( key=config.oauth_token_key, secret=config.oauth_token_secret) else: webbrowser.open(oauth_client.get_signin_url()) oauth_client.set_oauth_verifier(raw_input('Enter OAuth verifier: ')) write_config_file(oauth_client.token) etsy_api = Etsy(etsy_oauth_client=oauth_client, etsy_env=etsy_env, log=my_log)
if oauth_token: config_file.write("oauth_token_key = %r\n" % oauth_token.key) config_file.write("oauth_token_secret = %r\n" % oauth_token.secret) try: import config except ImportError: config = None write_config_file(oauth_token=None) if (hasattr(config, 'oauth_consumer_key') and hasattr(config, 'oauth_consumer_secret')): oauth_client = EtsyOAuthClient( oauth_consumer_key=config.oauth_consumer_key, oauth_consumer_secret=config.oauth_consumer_secret, etsy_env=etsy_env) else: sys.stderr.write('ERROR: You must set oauth_consumer_key and ' 'oauth_consumer_secret in config.py\n') sys.exit(1) if (hasattr(config, 'oauth_token_key') and hasattr(config, 'oauth_token_secret')): oauth_client.token = oauth.Token(key=config.oauth_token_key, secret=config.oauth_token_secret) else: webbrowser.open(oauth_client.get_signin_url()) oauth_client.set_oauth_verifier(input('Enter OAuth verifier: ')) write_config_file(oauth_client.token)