<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import logging <EOL> from datetime import timedelta as py_timedelta <EOL> from django import test <EOL> from services . common import misc as sn_misc <EOL> from services . common import simulation as simulator <EOL> from services . common import helpers as db_tools <EOL> from services . configuration . models import segments as segment_models <EOL> from services . simulation . models import groundtracks as groundtrack_models <EOL> from services . simulation . models import passes as pass_models <EOL> from services . simulation import periodictasks as simulation_tasks <EOL> class PeriodicSimulationTest ( test . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __verbose_testing = False <EOL> if not self . __verbose_testing : <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( level = logging . CRITICAL ) <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( level = logging . CRITICAL ) <EOL> self . __user = db_tools . create_user_profile ( ) <EOL> self . __request_1 = db_tools . create_request ( user_profile = self . __user ) <EOL> self . __gs_1_id = '<STR_LIT>' <EOL> self . __gs_1 = db_tools . create_gs ( <EOL> user_profile = self . __user , identifier = self . __gs_1_id <EOL> ) <EOL> self . __sc_1_id = '<STR_LIT>' <EOL> self . __sc_1_tle_id = '<STR_LIT>' <EOL> self . __sc_1 = db_tools . create_sc ( <EOL> user_profile = self . __user , <EOL> identifier = self . __sc_1_id , tle_id = self . __sc_1_tle_id , <EOL> ) <EOL> def test_simulation_error ( self ) : <EOL> """<STR_LIT>""" <EOL> sim = simulator . OrbitalSimulator ( ) <EOL> sim . set_debug ( fail = True ) <EOL> sc = segment_models . Spacecraft . objects . get ( identifier = '<STR_LIT>' ) <EOL> try : <EOL> sim . calculate_groundtrack ( sc . tle ) <EOL> self . fail ( '<STR_LIT>' ) <EOL> except Exception : <EOL> pass <EOL> def test_propagate_groundtracks ( self ) : <EOL> """<STR_LIT>""" <EOL> sc = segment_models . Spacecraft . objects . get ( identifier = '<STR_LIT>' ) <EOL> gt_i = groundtrack_models . GroundTrack . objects . get ( spacecraft = sc ) <EOL> self . assertNotEqual ( <EOL> len ( gt_i . timestamp ) , <NUM_LIT:0> , '<STR_LIT>' <EOL> ) <EOL> groundtrack_models . GroundTrack . objects . propagate ( ) <EOL> gt_f = groundtrack_models . GroundTrack . objects . get ( spacecraft = sc ) <EOL> self . assertNotEqual ( <EOL> len ( gt_f . timestamp ) , <NUM_LIT:0> , '<STR_LIT>' <EOL> ) <EOL> self . assertNotEqual ( <EOL> len ( gt_i . timestamp ) , len ( gt_f . timestamp ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_passes_clean ( self ) : <EOL> """<STR_LIT>""" <EOL> pass_models . PassSlots . objects . propagate ( ) <EOL> sc_passes_n_1 = pass_models . PassSlots . objects . filter ( <EOL> spacecraft = self . __sc_1 <EOL> ) . count ( ) <EOL> simulation_tasks . clean_passes ( ) <EOL> sc_passes_n_2 = pass_models . PassSlots . objects . filter ( <EOL> spacecraft = self . __sc_1 <EOL> ) . count ( ) <EOL> self . assertEquals ( sc_passes_n_1 , sc_passes_n_2 ) <EOL> interval_2 = ( <EOL> sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:5> ) , <EOL> sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:6> ) <EOL> ) <EOL> pass_models . PassSlots . objects . propagate ( interval = interval_2 ) <EOL> sc_passes_n_3 = pass_models . PassSlots . objects . filter ( <EOL> spacecraft = self . __sc_1 <EOL> ) . count ( ) <EOL> self . assertGreater ( sc_passes_n_3 , sc_passes_n_2 ) <EOL> simulation_tasks . clean_passes ( <EOL> threshold = sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:10> ) <EOL> ) <EOL> sc_passes_n_4 = pass_models . PassSlots . objects . filter ( <EOL> spacecraft = self . __sc_1 <EOL> ) . count ( ) <EOL> self . assertEquals ( sc_passes_n_4 , <NUM_LIT:0> ) <EOL> def test_groundtracks_clean ( self ) : <EOL> """<STR_LIT>""" <EOL> groundtrack_models . GroundTrack . objects . propagate ( ) <EOL> sc_gts_n_1 = len ( <EOL> groundtrack_models . GroundTrack . objects . get ( <EOL> spacecraft = self . __sc_1 <EOL> ) . timestamp <EOL> ) <EOL> simulation_tasks . clean_passes ( ) <EOL> sc_gts_n_2 = len ( <EOL> groundtrack_models . GroundTrack . objects . get ( <EOL> spacecraft = self . __sc_1 <EOL> ) . timestamp <EOL> ) <EOL> self . assertEquals ( sc_gts_n_1 , sc_gts_n_2 ) <EOL> interval_2 = ( <EOL> sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:5> ) , <EOL> sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:6> ) <EOL> ) <EOL> groundtrack_models . GroundTrack . objects . propagate ( interval = interval_2 ) <EOL> sc_gts_n_3 = len ( <EOL> groundtrack_models . GroundTrack . objects . get ( <EOL> spacecraft = self . __sc_1 <EOL> ) . timestamp <EOL> ) <EOL> self . assertGreater ( sc_gts_n_3 , sc_gts_n_2 ) <EOL> simulation_tasks . clean_groundtracks ( <EOL> threshold = sn_misc . get_next_midnight ( ) + py_timedelta ( days = <NUM_LIT:10> ) <EOL> ) <EOL> sc_gts_n_4 = len ( <EOL> groundtrack_models . GroundTrack . objects . get ( <EOL> spacecraft = self . __sc_1 <EOL> ) . timestamp <EOL> ) <EOL> self . assertEquals ( sc_gts_n_4 , <NUM_LIT:0> ) </s>
