示例#1
0
def main(**kwargs):
    EagleDataLogger.get_new_rainforest_data(
    	db,
    	{
	        'cloud_id' : kwargs['cloud_id'],
	        'last_timestamp' : kwargs['last_timestamp'],
	    })
示例#2
0
 def test_get_s3_keyname(self):
     self.assertEqual(
         EagleDataLogger.get_s3_keyname(
             {'cloud_id' : 99999},
             util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,2,3,4)),
         ),
         'rainforest-logs/99999/2015/01/02/iseif-rainforest-99999-2015-01-02-03.jl.gz'
     )
示例#3
0
 def test_get_log_filename(self):
     self.assertEqual(
         EagleDataLogger.get_log_filename(
             {'cloud_id' : 99999},
             util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,2,3,4)),
         ),
         '2015-01-02-03/iseif-rainforest-99999-2015-01-02-03.jl'
     )
示例#4
0
    def test_get_last_timestamp(self):
        self.assertEqual(
            EagleDataLogger.get_last_timestamp([
                {'TimeStamp': 20},
                {'TimeStamp': -20},
                {'TimeStamp': 105},
                {'TimeStamp': 120},
                {'TimeStamp': 200},
            ]),
            200
        )

        self.assertEqual(
            EagleDataLogger.get_last_timestamp([
                {'TimeStamp': 20},
            ]),
            20
        )
示例#5
0
    def test_is_new_log_filename(self):

        x = util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0))

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0))
            ),
            False
        )

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,30))
            ),
            False
        )

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,59))
            ),
            False
        )

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,1,0))
            ),
            True
        )

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,0,59)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,1,0))
            ),
            True
        )

        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,1,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,2,3,4))
            ),
            True
        )

        #This case should never occur
        self.assertEqual(
            EagleDataLogger.is_new_log_filename(
                {'cloud_id' : 99999},
                util.convert_datetime_to_unix_epoch(datetime.datetime(2015,1,1,1,0)),
                util.convert_datetime_to_unix_epoch(datetime.datetime(2014,1,1,1,0))
            ),
            True
        )