# Path: radarpost/mailbox.py
# def create_mailbox(couchdb, dbname):
#     """
#     create a mailbox on the given server with the given name.
#     
#     raises PreconditionFailed if a database with the given name 
#            already exists.
#     raises ValueError if name is not a valid mailbox name.
#     """
#     db = couchdb.create(dbname)
#     bless_mailbox(db)
#     return db
# 
# Path: radarpost/config.py
# def load_config(*filenames):
#     defaults = {}
#     for get_defaults in plugins.get(CONFIG_INI_DEFAULTS_PLUGIN):
#         defaults.update(get_defaults())
#     
#     parser = SafeConfigParser(defaults=defaults)
#     
#     for filename in filenames:
#         conf_file = open(filename, 'r')
#         parser.readfp(conf_file)
# 
#     config = {}
#     for section in parser.sections():
#         for key, val in parser.items(section):
#             if section == 'main': 
#                 config[key] = val
#             else: 
#                 config['%s.%s' % (section, key)] = val
# 
#     # there may need to be a pre-configuration step here to 
#     # enable / disable plugins based on configuration before
#     # running config plugins.
# 
#     for parser in plugins.get(CONFIG_INI_PARSER_PLUGIN):
#         parser(config)
# 
#     return config


import os
import copy
import random
import struct
from os import path
from os.path import dirname as dn
from couchdb import Server
from couchdb.http import PreconditionFailed
from datetime import datetime, timedelta
from hashlib import sha1
from radarpost.mailbox import create_mailbox as _create_mailbox
from radarpost.config import load_config


TEST_INI_KEY = 'RADAR_TEST_CONFIG'
DEFAULT_RADAR_TEST_CONFIG = path.join(dn(dn(dn(__file__))), 'test.ini')
TEST_DATA_DIR = path.join(dn(__file__), 'data')
TEST_MAILBOX_ID = 'rp_test_mailbox'

def get_config_filename():
    filename = os.environ.get('RADAR_TEST_CONFIG', None)
    if filename is None:
        filename = DEFAULT_RADAR_TEST_CONFIG
    return filename

def load_test_config():

# Path: radarpost/mailbox.py
# def create_mailbox(couchdb, dbname):
#     """
#     create a mailbox on the given server with the given name.
#     
#     raises PreconditionFailed if a database with the given name 
#            already exists.
#     raises ValueError if name is not a valid mailbox name.
#     """
#     db = couchdb.create(dbname)
#     bless_mailbox(db)
#     return db
# 
# Path: radarpost/config.py
# def load_config(*filenames):
#     defaults = {}
#     for get_defaults in plugins.get(CONFIG_INI_DEFAULTS_PLUGIN):
#         defaults.update(get_defaults())
#     
#     parser = SafeConfigParser(defaults=defaults)
#     
#     for filename in filenames:
#         conf_file = open(filename, 'r')
#         parser.readfp(conf_file)
# 
#     config = {}
#     for section in parser.sections():
#         for key, val in parser.items(section):
#             if section == 'main': 
#                 config[key] = val
#             else: 
#                 config['%s.%s' % (section, key)] = val
# 
#     # there may need to be a pre-configuration step here to 
#     # enable / disable plugins based on configuration before
#     # running config plugins.
# 
#     for parser in plugins.get(CONFIG_INI_PARSER_PLUGIN):
#         parser(config)
# 
#     return config


# Path: radarpost/tests/helpers.py
import os
import copy
import random
import struct
from os import path
from os.path import dirname as dn
from couchdb import Server
from couchdb.http import PreconditionFailed
from datetime import datetime, timedelta
from hashlib import sha1
from radarpost.mailbox import create_mailbox as _create_mailbox
from radarpost.config import load_config



TEST_INI_KEY = 'RADAR_TEST_CONFIG'
DEFAULT_RADAR_TEST_CONFIG = path.join(dn(dn(dn(__file__))), 'test.ini')
TEST_DATA_DIR = path.join(dn(__file__), 'data')
TEST_MAILBOX_ID = 'rp_test_mailbox'

def get_config_filename():
    filename = os.environ.get('RADAR_TEST_CONFIG', None)
    if filename is None:
        filename = DEFAULT_RADAR_TEST_CONFIG
    return filename

def load_test_config():

    return load_config(get_config_filename())