示例#1
0
 def setUp(self):
     base_path= os.path.dirname(os.path.abspath(__file__))
     packages_path = os.path.join(base_path, 'packages')
     self.psybase = test_util.create_psybase(package_directory = [packages_path,])
     self.db_project = test_util.create_dbtest_project(self.psybase)
     self.db_base_dir = self.db_project.base_dir
     self.db_user = self.db_project.activeUser
    def setUpClass(cls):
        # Configure the logger.
        cls.logger = logging.getLogger('psysmon')
        cls.logger.setLevel('DEBUG')
        cls.logger.addHandler(psysmon.getLoggerHandler(log_level = 'DEBUG'))

        cls.psybase = create_psybase()
示例#3
0
 def setUp(self):
     self.psybase = test_util.create_psybase(package_directory=[
         self.packages_path,
     ])
     self.db_project = test_util.create_dbtest_project(self.psybase)
     self.db_base_dir = self.db_project.base_dir
     self.db_user = self.db_project.activeUser
示例#4
0
def run():
    if len(sys.argv) <= 2:
        print("At least 2 arguments required (project_file, username).\n")
        sys.exit()

    project_file = sys.argv[1]
    user_name = sys.argv[2]

    if len(sys.argv) == 4:
        user_pwd = sys.argv[3]
    else:
        user_pwd = ''

    logger = logging.getLogger('psysmon')
    logger.setLevel(psysmon.logConfig['level'])
    logger.addHandler(psysmon.getLoggerHandler())

    psybase = create_psybase()
    userdata = {}
    userdata['user'] = user_name
    userdata['pwd'] = user_pwd
    psybase.load_json_project(project_file, user_name, user_pwd)

    clear_project_database_tables(psybase.project)
    psybase.stop_project_server()
示例#5
0
 def setUp(self):
     base_path = os.path.dirname(os.path.abspath(__file__))
     packages_path = os.path.join(base_path, 'packages')
     self.psybase = test_util.create_psybase(package_directory=[
         packages_path,
     ])
     self.base_dir = tempfile.mkdtemp()
示例#6
0
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('DEBUG')
        logger.addHandler(psysmon.getLoggerHandler())

        cls.psybase = create_psybase()
        cls.project = create_full_project(cls.psybase)
        print "In setUpClass...\n"
示例#7
0
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('INFO')
        logger.addHandler(psysmon.getLoggerHandler())

        # Create an empty project.
        cls.psybase = create_psybase()
        cls.project = create_empty_project(cls.psybase)
        cls.project.dbEngine.echo = False
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('DEBUG')
        logger.addHandler(psysmon.getLoggerHandler())

        clean_unittest_database()

        cls.psybase = create_psybase()
        create_full_project(cls.psybase)
        cls.project = cls.psybase.project
        cls.project.dbEngine.echo = True
示例#9
0
    def setUpClass(cls):
        # Configure the logger.
        cls.logger = logging.getLogger('psysmon')
        cls.logger.setLevel('DEBUG')
        cls.logger.addHandler(psysmon.getLoggerHandler())

        # Clean the unittest database.
        test_util.clean_unittest_database()

        # Create the test project.
        cls.psybase = test_util.create_psybase()
        cls.project = test_util.create_full_project(cls.psybase)
示例#10
0
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('DEBUG')
        logger.addHandler(psysmon.getLoggerHandler())

        cls.data_path = os.path.dirname(os.path.abspath(__file__))
        cls.data_path = os.path.join(cls.data_path, 'data')

        cls.psybase = create_psybase()
        cls.project = create_empty_project(cls.psybase)
        cls.project.dbEngine.echo = True
示例#11
0
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('INFO')
        logger.addHandler(psysmon.getLoggerHandler())

        # Set the data path.
        cls.data_path = os.path.dirname(os.path.abspath(__file__))
        cls.data_path = os.path.join(cls.data_path, 'data')

        # Create an empty project.
        cls.psybase = create_psybase()
        cls.project = create_full_project(cls.psybase)
        cls.project.dbEngine.echo = False
示例#12
0
    def setUpClass(cls):
        # Configure the logger.
        cls.logger = logging.getLogger('psysmon')
        cls.logger.setLevel('DEBUG')
        cls.logger.addHandler(psysmon.getLoggerHandler(log_level='DEBUG'))

        drop_database_tables(db_dialect='mysql',
                             db_driver=None,
                             db_host='localhost',
                             db_name='psysmon_unit_test',
                             db_user='******',
                             db_pwd='test',
                             project_name='unit_test')

        cls.psybase = create_psybase()
        cls.project = create_empty_project(cls.psybase)
        cls.project.dbEngine.echo = False
示例#13
0
    def setUpClass(cls):
        # Configure the logger.
        logger = logging.getLogger('psysmon')
        logger.setLevel('INFO')
        logger.addHandler(psysmon.getLoggerHandler())

        test_util.drop_database_tables(db_dialect='mysql',
                                       db_driver=None,
                                       db_host='localhost',
                                       db_name='psysmon_unit_test',
                                       db_user='******',
                                       db_pwd='test',
                                       project_name='unit_test')

        cls.psybase = test_util.create_psybase()
        test_util.create_full_project(cls.psybase)
        cls.project = cls.psybase.project
        cls.project.dbEngine.echo = False
        logger.setLevel('DEBUG')
示例#14
0
def run():
    if len(sys.argv) <= 2:
        print "At least 2 arguments required (project_file, username).\n"
        sys.exit()

    project_file = sys.argv[1]
    user_name = sys.argv[2]

    if len(sys.argv) == 4:
        user_pwd = sys.argv[3]
    else:
        user_pwd = ''

    psybase = create_psybase()
    userdata = {}
    userdata['user'] = user_name
    userdata['pwd'] = user_pwd
    psybase.load_json_project(project_file, user_name, user_pwd)

    clear_project_database_tables(psybase.project)
    psybase.stop_project_server()
    def test_json_waveclient_deserialization(self):
        '''
        '''
        import psysmon.core.waveclient

        packages_path = os.path.dirname(os.path.abspath(__file__))
        packages_path = os.path.join(packages_path, 'waveclient_packages')
        psybase = test_util.create_psybase(package_directory=[
            packages_path,
        ])
        project = test_util.create_dbtest_project(psybase)
        project.createDatabaseStructure(psybase.packageMgr.packages)

        # Set the maxDiff attribute to None to enable long output of
        # non-equal strings tested with assertMultiLineEqual.
        self.maxDiff = None

        # Set the createTime of the project to a known value.
        project.createTime = UTCDateTime('2013-01-01T00:00:00')

        # Add a waveclient to the project.
        waveclient = psysmon.core.waveclient.PsysmonDbWaveClient(
            'db client', project)
        project.addWaveClient(waveclient)
        project.defaultWaveclient = 'db client'

        encoder = util.ProjectFileEncoder()
        decoder = util.ProjectFileDecoder()
        json_project = encoder.encode(project)
        project_obj = decoder.decode(json_project)

        # TODO: Test the project_obj for validity.
        print project_obj.waveclient['db client'].mode

        psybase.stop_project_server()
        base_dir = project.base_dir
        test_util.drop_project_database_tables(project)
        shutil.rmtree(base_dir)
示例#16
0
    def test_json_waveclient_serialization(self):
        '''
        '''
        import psysmon.core.waveclient

        packages_path = os.path.dirname(os.path.abspath(__file__))
        packages_path = os.path.join(packages_path, 'waveclient_packages')
        psybase = test_util.create_psybase(package_directory=[
            packages_path,
        ])
        project = test_util.create_dbtest_project(psybase)
        project.createDatabaseStructure(psybase.packageMgr.packages)

        # Set the maxDiff attribute to None to enable long output of
        # non-equal strings tested with assertMultiLineEqual.
        self.maxDiff = None

        # Set the createTime of the project to a known value.
        project.createTime = UTCDateTime('2013-01-01T00:00:00')

        # Add a waveclient to the project.
        waveclient = psysmon.core.waveclient.PsysmonDbWaveClient(
            'db client', project)
        project.addWaveClient(waveclient)
        project.defaultWaveclient = 'db client'

        encoder = util.ProjectFileEncoder()

        # Test empty project.
        expected_result = '''{
    "__baseclass__": [], 
    "__class__": "Project", 
    "__module__": "psysmon.core.project", 
    "createTime": {
        "__baseclass__": [
            "object"
        ], 
        "__class__": "UTCDateTime", 
        "__module__": "obspy.core.utcdatetime", 
        "utcdatetime": "2013-01-01T00:00:00"
    }, 
    "dbDialect": "mysql", 
    "dbDriver": null, 
    "dbHost": "localhost", 
    "dbName": "psysmon_unit_test", 
    "db_version": {
        "geometry": "0.1.1", 
        "obspyImportWaveform": "0.1.1"
    }, 
    "defaultWaveclient": "db client", 
    "name": "Unit Test", 
    "pkg_version": {
        "geometry": "0.1.1", 
        "obspyImportWaveform": "0.1.1"
    }, 
    "scnlDataSources": {}, 
    "user": [
        {
            "__baseclass__": [], 
            "__class__": "User", 
            "__module__": "psysmon.core.project", 
            "activeCollection": null, 
            "agency_name": "University of Test", 
            "agency_uri": "at.uot", 
            "author_name": "Stefan Test", 
            "author_uri": "stest", 
            "collection": {}, 
            "mode": "admin", 
            "name": "unit_test"
        }
    ], 
    "waveclient": {
        "db client": {
            "__baseclass__": [
                "WaveClient"
            ], 
            "__class__": "PsysmonDbWaveClient", 
            "__module__": "psysmon.core.waveclient", 
            "name": "db client", 
            "options": {}, 
            "stock_window": 3600
        }
    }
}'''

        try:
            self.assertMultiLineEqual(encoder.encode(project), expected_result)
        finally:
            base_dir = project.base_dir
            psybase.stop_project_server()
            test_util.drop_project_database_tables(project)
            shutil.rmtree(base_dir)