예제 #1
0
 def test_connection(self):
     config = Config(config_file_path)
     config.reload(config_file_path)
     config.set('General', 'debug', 'yes')
     rta_evt3_db_mysql = RTA_EVT3_DB('mysql', config_file_path)
     rta_evt3_db_redis = RTA_EVT3_DB('redis-basic', config_file_path)
     self.assertEqual(True, rta_evt3_db_mysql.dbConnector.testConnection())
     self.assertEqual(True, rta_evt3_db_redis.dbConnector.testConnection())
예제 #2
0
def sendMockData():
    config = Config(configFilePath)

    redisConn = redis.Redis(host=config.get('Redis', 'host'),
                            port=6379,
                            db=config.get('Redis', 'dbname'),
                            password=config.get('Redis', 'password'))
    # pubsub = redisConn.pubsub()

    dtrInputChannel = config.get('Dtr', 'inputchannel')

    mockDetectionData = getMockData()

    print("Example of data: ", mockDetectionData[0])

    # SORTING...

    for data in reversed(mockDetectionData):
        if not "dataType" in mockDetectionData:
            data["dataType"] = 'detection'

        if not "instrument_id" in mockDetectionData:
            data["instrument_id"] = instrument_id

        if not "observation_id" in mockDetectionData:
            data["observation_id"] = observation_id

        if not "analysis_session_type_id" in mockDetectionData:
            data["analysis_session_type_id"] = analysis_session_type_id

        sleep(randint(int(sleepMin), int(sleepMax)))

        print("Publish ", data, " on DTR channel ", dtrInputChannel)

        redisConn.publish(dtrInputChannel, data)

    redisConn.publish(dtrInputChannel, 'STOP')
예제 #3
0
 def test_file_not_found_wrong_path(self):
     config = Config('', False)
     self.assertRaises(FileNotFoundError, config.parseConfigFile,
                       '../../../Configs/akjdiajwnd')
예제 #4
0
 def test_wrong_attribute(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('General', 'Paperino'))
예제 #5
0
 def test_wrong_section(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('Pluto', 'Paperino'))
예제 #6
0
 def test_priority_to_env_var(self):
     environ['RTALIBCONFIGFILE'] = config_file_path
     config = Config('../../../Configs/wrongconfigfile')
     self.assertEqual(True, bool(config.get()))
예제 #7
0
 def test_singleton(self):
     config = Config(config_file_path)
     config.set('General', 'batchsize', 666)
     config = Config(config_file_path)
     self.assertEqual(666, config.get('General', 'batchsize'))
     config.reload(config_file_path)
예제 #8
0
 def test_file_found_with_relative_path(self):
     config = Config(config_file_path)
     self.assertEqual(True, bool(config.get()))
예제 #9
0
 def test_file_found_with_environment_variable(self):
     environ['RTALIBCONFIGFILE'] = config_file_path
     config = Config()
     self.assertEqual(True, bool(config.get()))
예제 #10
0
파일: UtilsUT.py 프로젝트: rta-pipe/RTAlib
def getConfig(config_file_path, debug, reload=False):
    config = Config(config_file_path)
    if reload:
        config.reload(config_file_path)
    config.set('General', 'debug', debug)
    return config
예제 #11
0
 def test_file_not_found_wrong_env_var_path(self):
     environ[
         'RTALIBCONFIGFILE'] = '../wrong/path/Configs/rtalibconfig_testing'
     config = Config('', False)
     self.assertRaises(FileNotFoundError, config.parseConfigFile, '')
예제 #12
0
 def test_bool_false_cast(self):
     config = Config(config_file_path)
     config.set('General', 'debug', 'alksjdlkasjd')
     self.assertEqual(
         True, isinstance(config.get('General', 'debug', 'bool'), bool))
     self.assertEqual(False, config.get('General', 'debug', 'bool'))
예제 #13
0
 def test_no_path_no_env_var_provided(self):
     if 'RTALIBCONFIGFILE' in environ:
         del environ['RTALIBCONFIGFILE']
     config = Config('', False)
     self.assertRaises(Exception, config.parseConfigFile, '')
예제 #14
0
 def test_bool_true_cast(self):
     config = Config(config_file_path)
     config.set('General', 'debug', 'yes')
     self.assertEqual(
         True, isinstance(config.get('General', 'debug', 'bool'), bool))
     self.assertEqual(True, config.get('General', 'debug', 'bool'))
예제 #15
0
 def test_float_cast(self):
     config = Config(config_file_path)
     config.set('General', 'mjdref', 666.666)
     self.assertEqual(
         True, isinstance(config.get('General', 'mjdref', 'float'), float))
     self.assertEqual(666.666, config.get('General', 'mjdref', 'float'))
예제 #16
0
 def test_set_and_get_value(self):
     config = Config(config_file_path)
     config.set('General', 'batchsize', 666)
     self.assertEqual(666, config.get('General', 'batchsize'))
예제 #17
0
 def test_get_section(self):
     config = Config(config_file_path)
     self.assertEqual(5, len(config.get('MySql')))
예제 #18
0
 def test_wrong_section_no_attribute(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('Pluto'))