# Path: spec/python/db_connection.py
# TEST_DATABASE_MYSQL = 'samapper_test'
# TEST_DATABASE_SQLITE = '/tmp/sam_test.db'
# class Mocker(object):
# class Session(dict):
# class env(object):
#     def __init__(self, *args, **kwargs):
#     def __getitem__(self, k):
#     def __setitem__(self, k, v):
#     def __getattr__(self, name):
#         def receiver(*args, **kwargs):
#     def __call__(self, *args, **kwargs):
#     def clear(self):
#     def was_called(self, name, *args, **kwargs):
#     def kill(self):
#     def __init__(self, mock_input=False, login_active=None, mock_session=False, mock_render=False, lang='en'):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def make_timestamp(timestring):
# def unix_timestamp_to_datetime(stamp):
# def get_test_db_connection():
# def setup_datasources(db, sub_id):
# def template_sql(path, *args):
# def setup_network(db, sub_id, ds_id):
# def setup_node_extras(sub_id):
# 
# Path: sam/constants.py
# LDAP = {
#     'connection_string': config.get('LDAP', 'connection_string', default='')
# }
# def enable_local_mode():
# def init_urls():
# def find_url(target):
# def get_navbar(lang):
# 
# Path: sam/launcher.py
# VALID_ARGS = ['format=', 'port=', 'target=', 'dest=', 'sub=', 'local', 'whois', 'wsgi']
# VALID_TARGETS = ['local', 'aggregator', 'collector', 'collector_stream',
#                  'webserver', 'import', 'test_dummy', 'template']
# def main(argv=None):
# def parse_args(argv):
# def launch_webserver(parsed, args):
# def launch_collector(parsed, args):
# def launch_collector_stream(parsed, args):
# def launch_aggregator(parsed, args):
# def launch_importer(parsed, args):
# def launch_template_tester(parsed, args):
# def create_local_settings(db, sub, ds_key):
# def check_database():
# def launch_whois_service(db, sub):
# def launch_localmode(parsed, args):
#     def spawn_coll(stdin):
# def testing_entrypoint(environment, argv):
# 
# Path: sam/server_webserver.py
# def check_database():
# def create_session(app):
# def localization_hook():
# def start_server(port):
# def start_wsgi():


import os
import sys
import signal
import multiprocessing
import time
from spec.python import db_connection
from sam import constants, launcher, preprocess
from sam import server_webserver
from sam import server_collector
from sam import server_aggregator
from sam.importers import import_base
from sam.models.livekeys import LiveKeys
from sam.models.datasources import Datasources
from sam.models import nodes
    assert args == []

    argv = 'launcher.py --target=collector_stream'.split()
    parsed, args = launcher.parse_args(argv)
    assert parsed == {
        'format': None,
        'port': None,
        'target': 'collector_stream',
        'whois': False,
        'wsgi': False,
        'dest': 'default',
        'sub': None
    }
    assert args == []

    argv = 'launcher.py --target=import ../data/syslog'.split()
    parsed, args = launcher.parse_args(argv)
    assert parsed == {
        'format': None,
        'port': None,
        'target': 'import',
        'whois': False,
        'wsgi': False,
        'dest': 'default',
        'sub': None
    }
    assert args == ['../data/syslog']


def test_launch_webserver():

# Path: spec/python/db_connection.py
# TEST_DATABASE_MYSQL = 'samapper_test'
# TEST_DATABASE_SQLITE = '/tmp/sam_test.db'
# class Mocker(object):
# class Session(dict):
# class env(object):
#     def __init__(self, *args, **kwargs):
#     def __getitem__(self, k):
#     def __setitem__(self, k, v):
#     def __getattr__(self, name):
#         def receiver(*args, **kwargs):
#     def __call__(self, *args, **kwargs):
#     def clear(self):
#     def was_called(self, name, *args, **kwargs):
#     def kill(self):
#     def __init__(self, mock_input=False, login_active=None, mock_session=False, mock_render=False, lang='en'):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def make_timestamp(timestring):
# def unix_timestamp_to_datetime(stamp):
# def get_test_db_connection():
# def setup_datasources(db, sub_id):
# def template_sql(path, *args):
# def setup_network(db, sub_id, ds_id):
# def setup_node_extras(sub_id):
# 
# Path: sam/constants.py
# LDAP = {
#     'connection_string': config.get('LDAP', 'connection_string', default='')
# }
# def enable_local_mode():
# def init_urls():
# def find_url(target):
# def get_navbar(lang):
# 
# Path: sam/launcher.py
# VALID_ARGS = ['format=', 'port=', 'target=', 'dest=', 'sub=', 'local', 'whois', 'wsgi']
# VALID_TARGETS = ['local', 'aggregator', 'collector', 'collector_stream',
#                  'webserver', 'import', 'test_dummy', 'template']
# def main(argv=None):
# def parse_args(argv):
# def launch_webserver(parsed, args):
# def launch_collector(parsed, args):
# def launch_collector_stream(parsed, args):
# def launch_aggregator(parsed, args):
# def launch_importer(parsed, args):
# def launch_template_tester(parsed, args):
# def create_local_settings(db, sub, ds_key):
# def check_database():
# def launch_whois_service(db, sub):
# def launch_localmode(parsed, args):
#     def spawn_coll(stdin):
# def testing_entrypoint(environment, argv):
# 
# Path: sam/server_webserver.py
# def check_database():
# def create_session(app):
# def localization_hook():
# def start_server(port):
# def start_wsgi():


# Path: spec/python/test_launcher.py
import os
import sys
import signal
import multiprocessing
import time
from spec.python import db_connection
from sam import constants, launcher, preprocess
from sam import server_webserver
from sam import server_collector
from sam import server_aggregator
from sam.importers import import_base
from sam.models.livekeys import LiveKeys
from sam.models.datasources import Datasources
from sam.models import nodes

    assert args == []

    argv = 'launcher.py --target=collector_stream'.split()
    parsed, args = launcher.parse_args(argv)
    assert parsed == {
        'format': None,
        'port': None,
        'target': 'collector_stream',
        'whois': False,
        'wsgi': False,
        'dest': 'default',
        'sub': None
    }
    assert args == []

    argv = 'launcher.py --target=import ../data/syslog'.split()
    parsed, args = launcher.parse_args(argv)
    assert parsed == {
        'format': None,
        'port': None,
        'target': 'import',
        'whois': False,
        'wsgi': False,
        'dest': 'default',
        'sub': None
    }
    assert args == ['../data/syslog']


def test_launch_webserver():

    old_start_wsgi = server_webserver.start_wsgi