# Path: montage/utils.py
# CUR_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJ_PATH = os.path.dirname(CUR_PATH)
# USER_ENV_MAP = {'tools.montage-dev': 'devlabs',
#                 'tools.montage': 'prod',
#                 'tools.montage-beta': 'beta'}
# DEFAULT_ENV_NAME = 'dev'
# DEFAULT_SERIES = {'name': 'Unofficial',
#                   'description': 'For unofficial campaigns, whether for testing or just for fun!',
#                   'url': 'TODO add docs url'}  # TODO: status is always active
# DEVTEST_CONFIG = {'oauth_consumer_token': None,
#                   'oauth_secret_token': None,
#                   'cookie_secret': 'supertotallyrandomsecretcookiesecret8675309',
#                   'api_log_path': 'montage_api.log',
#                   'replay_log_path': 'montage_replay.log',
#                   'feel_log_path': 'montage_feel.log',
#                   'db_url': "sqlite:///tmp_montage.db",
#                   'db_echo': False,
#                   'debug': True,
#                   'superusers': ['Slaporte', 'MahmoudHashemi'],
#                   'dev_local_cookie_value': '"W7XGXxmUjl4kbkE0TWaFo4Oth50=?userid=NjAyNDQ3NA==&username=IlNsYXBvcnRlIg=="',
#                   '__file__': 'devtest-builtin',
#                   '__env__': 'devtest',
# }
# class MontageError(Exception):
# class PermissionDenied(MontageError, Forbidden):
# class DoesNotExist(MontageError, NotFound):
# class InvalidAction(MontageError, BadRequest):
# class NotImplementedResponse(MontageError, BadRequest, NotImplementedError):
# def to_unicode(obj):
# def encode_dict_to_bytes(query):
# def encode_value_to_bytes(value):
# def get_mw_userid(username):
# def get_threshold_map(ratings_map):
# def get_env_name():
# def load_env_config(env_name=None):
# def load_default_series():
# def check_schema(db_url, base_type, echo=False, autoexit=False):
# def format_date(date):
# def js_isoparse(date_str):
# def json_serial(obj):
# def parse_date(date):
# def weighted_choice(weighted_choices):
# def process_weighted_choices(wcp):
# def fast_weighted_choice(nsw, values):
# 
# Path: montage/log.py



import sys
import json
import os.path
import urllib
import urllib2
import urlparse
import argparse
import cookielib
        import pdb;pdb.set_trace()
            import pdb;pdb.set_trace()
    import pdb;pdb.set_trace()
    import pdb;pdb.set_trace()
from pprint import pprint
from lithoxyl import DEBUG, INFO
from montage import utils
from montage.log import script_log
* username
* assert_error/success
* http method (whether or not data is passed)
"""

# TODO: could use clastic to route-match based on URL to determine
# "role" of current route being tested
class SysTestClient(object):
    def __init__(self, base_url, default_role='public'):
        self.base_url = base_url.rstrip('/')
        self.default_role = default_role
        # TODO: default user?

    def fetch(self, role_action, url, data=None, **kw):
        if not url.startswith('/'):
            raise ValueError('expected url starting with "/", not: %r' % url)
        role, sep, action = role_action.partition(':')
        role, action = (role, action) if sep else (self.default_role, role)
        print '>>', action, 'as', role,
        as_user = kw.pop('as_user', None)
        if as_user:
            print '(%s)' % as_user
        else:
            print

        log_level = kw.pop('log_level', INFO)
        error_code = kw.pop('error_code', None)
        if kw:
            raise TypeError('unexpected kwargs: %r' % kw.keys())


# Path: montage/utils.py
# CUR_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJ_PATH = os.path.dirname(CUR_PATH)
# USER_ENV_MAP = {'tools.montage-dev': 'devlabs',
#                 'tools.montage': 'prod',
#                 'tools.montage-beta': 'beta'}
# DEFAULT_ENV_NAME = 'dev'
# DEFAULT_SERIES = {'name': 'Unofficial',
#                   'description': 'For unofficial campaigns, whether for testing or just for fun!',
#                   'url': 'TODO add docs url'}  # TODO: status is always active
# DEVTEST_CONFIG = {'oauth_consumer_token': None,
#                   'oauth_secret_token': None,
#                   'cookie_secret': 'supertotallyrandomsecretcookiesecret8675309',
#                   'api_log_path': 'montage_api.log',
#                   'replay_log_path': 'montage_replay.log',
#                   'feel_log_path': 'montage_feel.log',
#                   'db_url': "sqlite:///tmp_montage.db",
#                   'db_echo': False,
#                   'debug': True,
#                   'superusers': ['Slaporte', 'MahmoudHashemi'],
#                   'dev_local_cookie_value': '"W7XGXxmUjl4kbkE0TWaFo4Oth50=?userid=NjAyNDQ3NA==&username=IlNsYXBvcnRlIg=="',
#                   '__file__': 'devtest-builtin',
#                   '__env__': 'devtest',
# }
# class MontageError(Exception):
# class PermissionDenied(MontageError, Forbidden):
# class DoesNotExist(MontageError, NotFound):
# class InvalidAction(MontageError, BadRequest):
# class NotImplementedResponse(MontageError, BadRequest, NotImplementedError):
# def to_unicode(obj):
# def encode_dict_to_bytes(query):
# def encode_value_to_bytes(value):
# def get_mw_userid(username):
# def get_threshold_map(ratings_map):
# def get_env_name():
# def load_env_config(env_name=None):
# def load_default_series():
# def check_schema(db_url, base_type, echo=False, autoexit=False):
# def format_date(date):
# def js_isoparse(date_str):
# def json_serial(obj):
# def parse_date(date):
# def weighted_choice(weighted_choices):
# def process_weighted_choices(wcp):
# def fast_weighted_choice(nsw, values):
# 
# Path: montage/log.py



# Path: run_server_test.py
import sys
import json
import os.path
import urllib
import urllib2
import urlparse
import argparse
import cookielib
        import pdb;pdb.set_trace()
            import pdb;pdb.set_trace()
    import pdb;pdb.set_trace()
    import pdb;pdb.set_trace()
from pprint import pprint
from lithoxyl import DEBUG, INFO
from montage import utils
from montage.log import script_log

* username
* assert_error/success
* http method (whether or not data is passed)
"""

# TODO: could use clastic to route-match based on URL to determine
# "role" of current route being tested
class SysTestClient(object):
    def __init__(self, base_url, default_role='public'):
        self.base_url = base_url.rstrip('/')
        self.default_role = default_role
        # TODO: default user?

    def fetch(self, role_action, url, data=None, **kw):
        if not url.startswith('/'):
            raise ValueError('expected url starting with "/", not: %r' % url)
        role, sep, action = role_action.partition(':')
        role, action = (role, action) if sep else (self.default_role, role)
        print '>>', action, 'as', role,
        as_user = kw.pop('as_user', None)
        if as_user:
            print '(%s)' % as_user
        else:
            print

        log_level = kw.pop('log_level', INFO)
        error_code = kw.pop('error_code', None)
        if kw:
            raise TypeError('unexpected kwargs: %r' % kw.keys())


        with script_log.action(log_level, 'fetch_url') as act: