# Path: cydra/test/fixtures/common.py
# class FixtureWithTempPath(Fixture):
#     """A fixture that creates a temporary directory"""
#     path = None
# 
#     def setUp(self, configDict):
#         super(FixtureWithTempPath, self).setUp(configDict)
#         self.path = tempfile.mkdtemp(prefix="cydratests_")
# 
#     def tearDown(self):
#         shutil.rmtree(self.path)
#         super(FixtureWithTempPath, self).tearDown()
# 
# Path: cydra/test/procutils.py
# class MonitoredDaemon(object):
#     name = ""
# 
#     stdout = ""
#     stderr = ""
# 
#     stdout_limit = None
#     stderr_limit = None
# 
#     stdout_thread = None
#     stderr_thread = None
# 
#     stdout_encountered = None
#     stderr_encountered = None
#     read_size = 4096
#     process = None
# 
#     def __init__(self, args, stdout_limit=None, stderr_limit=None, name=None,
#                  wait_for_stdout=None, wait_for_stdout_timeout=10,
#                  wait_for_stderr=None, wait_for_stderr_timeout=10):
#         """Spawn an monitor a daemon process"""
# 
#         self.name = name if name is not None else args[0]
#         self.stdout_limit = stdout_limit
#         self.stderr_limit = stderr_limit
# 
#         self.process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#         self.stdout_encountered = threading.Event()
#         self.stderr_encountered = threading.Event()
# 
#         self.stdout_thread = threading.Thread(target=self.read_stdout, kwargs={
#             'wait_for_stdout': wait_for_stdout
#         })
#         self.stderr_thread = threading.Thread(target=self.read_stderr, kwargs={
#             'wait_for_stderr': wait_for_stderr
#         })
# 
#         self.stdout_thread.start()
#         self.stderr_thread.start()
# 
#         if wait_for_stdout is not None:
#             self.stdout_encountered.wait(wait_for_stdout_timeout)
# 
#         if wait_for_stderr is not None:
#             self.stderr_encountered.wait(wait_for_stderr_timeout)
# 
#     def read_stdout(self, wait_for_stdout=None):
#         for line in iter(self.process.stdout.readline, b''):
#             sys.stdout.write("[D: " + self.name + "] " + line)
#             self.stdout += line
#             if wait_for_stdout is not None and wait_for_stdout in self.stdout:
#                 self.stdout_encountered.set()
# 
#             if self.stdout_limit is not None and len(self.stdout) > self.stdout_limit:
#                 self.stdout = self.stdout[-self.stdout_limit:]
# 
#     def read_stderr(self, wait_for_stderr=None):
#         for line in iter(self.process.stderr.readline, b''):
#             sys.stderr.write("[D: " + self.name + "] " + line)
#             self.stderr += line
#             if wait_for_stderr is not None and wait_for_stderr in self.stderr:
#                 self.stderr_encountered.set()
# 
#             if self.stderr_limit is not None and len(self.stderr) > self.stderr_limit:
#                 self.stderr = self.stderr[-self.stderr_limit:]


import socket
from cydra.test.fixtures.common import FixtureWithTempPath
from cydra.test.procutils import MonitoredDaemon
# -*- coding: utf-8 -*-
#
# Copyright 2013 Manuel Stocker <mensi@mensi.ch>
#
# This file is part of Cydra.
#
# Cydra is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Cydra is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Cydra.  If not, see http://www.gnu.org/licenses



class FileDatasource(FixtureWithTempPath):
    """Configure Cydra with the file datasource"""

    def setUp(self, configDict):
        super(FileDatasource, self).setUp(configDict)
        configDict.setdefault('components', {}).setdefault('cydra.datasource.file.FileDataSource', {})['base'] = self.path



# Path: cydra/test/fixtures/common.py
# class FixtureWithTempPath(Fixture):
#     """A fixture that creates a temporary directory"""
#     path = None
# 
#     def setUp(self, configDict):
#         super(FixtureWithTempPath, self).setUp(configDict)
#         self.path = tempfile.mkdtemp(prefix="cydratests_")
# 
#     def tearDown(self):
#         shutil.rmtree(self.path)
#         super(FixtureWithTempPath, self).tearDown()
# 
# Path: cydra/test/procutils.py
# class MonitoredDaemon(object):
#     name = ""
# 
#     stdout = ""
#     stderr = ""
# 
#     stdout_limit = None
#     stderr_limit = None
# 
#     stdout_thread = None
#     stderr_thread = None
# 
#     stdout_encountered = None
#     stderr_encountered = None
#     read_size = 4096
#     process = None
# 
#     def __init__(self, args, stdout_limit=None, stderr_limit=None, name=None,
#                  wait_for_stdout=None, wait_for_stdout_timeout=10,
#                  wait_for_stderr=None, wait_for_stderr_timeout=10):
#         """Spawn an monitor a daemon process"""
# 
#         self.name = name if name is not None else args[0]
#         self.stdout_limit = stdout_limit
#         self.stderr_limit = stderr_limit
# 
#         self.process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#         self.stdout_encountered = threading.Event()
#         self.stderr_encountered = threading.Event()
# 
#         self.stdout_thread = threading.Thread(target=self.read_stdout, kwargs={
#             'wait_for_stdout': wait_for_stdout
#         })
#         self.stderr_thread = threading.Thread(target=self.read_stderr, kwargs={
#             'wait_for_stderr': wait_for_stderr
#         })
# 
#         self.stdout_thread.start()
#         self.stderr_thread.start()
# 
#         if wait_for_stdout is not None:
#             self.stdout_encountered.wait(wait_for_stdout_timeout)
# 
#         if wait_for_stderr is not None:
#             self.stderr_encountered.wait(wait_for_stderr_timeout)
# 
#     def read_stdout(self, wait_for_stdout=None):
#         for line in iter(self.process.stdout.readline, b''):
#             sys.stdout.write("[D: " + self.name + "] " + line)
#             self.stdout += line
#             if wait_for_stdout is not None and wait_for_stdout in self.stdout:
#                 self.stdout_encountered.set()
# 
#             if self.stdout_limit is not None and len(self.stdout) > self.stdout_limit:
#                 self.stdout = self.stdout[-self.stdout_limit:]
# 
#     def read_stderr(self, wait_for_stderr=None):
#         for line in iter(self.process.stderr.readline, b''):
#             sys.stderr.write("[D: " + self.name + "] " + line)
#             self.stderr += line
#             if wait_for_stderr is not None and wait_for_stderr in self.stderr:
#                 self.stderr_encountered.set()
# 
#             if self.stderr_limit is not None and len(self.stderr) > self.stderr_limit:
#                 self.stderr = self.stderr[-self.stderr_limit:]


# Path: cydra/test/fixtures/datasource.py
import socket
from cydra.test.fixtures.common import FixtureWithTempPath
from cydra.test.procutils import MonitoredDaemon

# -*- coding: utf-8 -*-
#
# Copyright 2013 Manuel Stocker <mensi@mensi.ch>
#
# This file is part of Cydra.
#
# Cydra is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Cydra is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Cydra.  If not, see http://www.gnu.org/licenses



class FileDatasource(FixtureWithTempPath):
    """Configure Cydra with the file datasource"""

    def setUp(self, configDict):
        super(FileDatasource, self).setUp(configDict)
        configDict.setdefault('components', {}).setdefault('cydra.datasource.file.FileDataSource', {})['base'] = self.path



class MongoDatasource(FixtureWithTempPath):