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')
Exemple #2
0
 def test_wrong_section(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('Pluto', 'Paperino'))
Exemple #3
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)
Exemple #4
0
 def test_wrong_attribute(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('General', 'Paperino'))
Exemple #5
0
 def test_file_found_with_environment_variable(self):
     environ['RTALIBCONFIGFILE'] = config_file_path
     config = Config()
     self.assertEqual(True, bool(config.get()))
Exemple #6
0
 def test_priority_to_env_var(self):
     environ['RTALIBCONFIGFILE'] = config_file_path
     config = Config('../../../Configs/wrongconfigfile')
     self.assertEqual(True, bool(config.get()))
Exemple #7
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'))
Exemple #8
0
 def test_file_found_with_relative_path(self):
     config = Config(config_file_path)
     self.assertEqual(True, bool(config.get()))
Exemple #9
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'))
Exemple #10
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'))
Exemple #11
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'))
Exemple #12
0
 def test_get_section(self):
     config = Config(config_file_path)
     self.assertEqual(5, len(config.get('MySql')))
Exemple #13
0
 def test_wrong_section_no_attribute(self):
     config = Config(config_file_path)
     self.assertEqual(False, config.get('Pluto'))