<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import logging <EOL> from django import test <EOL> from services . common import helpers as db_tools <EOL> from services . configuration . models import segments as segment_models <EOL> from services . configuration . models import tle as tle_models <EOL> from services . leop import utils as leop_utils <EOL> from services . leop . models import launch as launch_models <EOL> from services . simulation . models import groundtracks as simulation_models <EOL> class TestLaunchModels ( test . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __verbose_testing = False <EOL> self . __launch_id = '<STR_LIT>' <EOL> self . __ufo_1_id = <NUM_LIT:1> <EOL> self . __ufo_1_cs = '<STR_LIT>' <EOL> self . __tle_l1 = db_tools . ISS_TLE [ <NUM_LIT:0> ] <EOL> self . __tle_l2 = db_tools . ISS_TLE [ <NUM_LIT:1> ] <EOL> self . __launch = db_tools . create_launch ( identifier = self . __launch_id ) <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> def test_create_launch ( self ) : <EOL> """<STR_LIT>""" <EOL> tle_id = leop_utils . generate_cluster_tle_id ( self . __launch_id ) <EOL> self . assertTrue ( <EOL> tle_models . TwoLineElement . objects . filter ( <EOL> identifier = tle_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> callsign = leop_utils . generate_cluster_callsign ( self . __launch_id ) <EOL> sc_id = leop_utils . generate_cluster_sc_identifier ( <EOL> self . __launch_id , callsign <EOL> ) <EOL> self . assertTrue ( <EOL> segment_models . Spacecraft . objects . filter ( <EOL> identifier = sc_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertTrue ( <EOL> simulation_models . GroundTrack . objects . filter ( <EOL> spacecraft = segment_models . Spacecraft . objects . get ( <EOL> identifier = sc_id <EOL> ) <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( sc_id ) ) <EOL> print ( '<STR_LIT>' + str ( tle_id ) ) <EOL> print ( '<STR_LIT>' + str ( callsign ) ) <EOL> def test_delete_launch ( self ) : <EOL> """<STR_LIT>""" <EOL> launch_id = '<STR_LIT>' <EOL> self . assertEqual ( <EOL> db_tools . create_launch ( identifier = launch_id ) . identifier , <EOL> launch_id , <EOL> '<STR_LIT>' <EOL> ) <EOL> launch_tle_id = leop_utils . generate_cluster_tle_id ( launch_id ) <EOL> self . assertTrue ( <EOL> tle_models . TwoLineElement . objects . filter ( <EOL> identifier = launch_tle_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> launch_models . Launch . objects . get ( identifier = launch_id ) . delete ( ) <EOL> self . assertFalse ( <EOL> tle_models . TwoLineElement . objects . filter ( <EOL> identifier = launch_tle_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_add_unknown ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> launch_models . Launch . objects . add_unknown ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) , <EOL> self . __ufo_1_id , <EOL> '<STR_LIT>' <EOL> ) <EOL> ufo = self . __launch . unknown_objects . get ( identifier = self . __ufo_1_id ) <EOL> self . assertEqual ( <EOL> ufo . identifier , self . __ufo_1_id , '<STR_LIT>' <EOL> ) <EOL> def test_remove_unknown ( self ) : <EOL> """<STR_LIT>""" <EOL> launch_models . Launch . objects . add_unknown ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> launch_models . Launch . objects . remove_unknown ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> self . assertFalse ( <EOL> self . __launch . unknown_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_identifiy ( self ) : <EOL> """<STR_LIT>""" <EOL> launch_models . Launch . objects . add_unknown ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> actual_id = launch_models . Launch . objects . identify ( <EOL> self . __launch_id , self . __ufo_1_id , self . __ufo_1_cs , <EOL> self . __tle_l1 , self . __tle_l2 <EOL> ) <EOL> self . assertEqual ( <EOL> actual_id [ <NUM_LIT:0> ] , self . __ufo_1_id , '<STR_LIT>' <EOL> ) <EOL> self . assertFalse ( <EOL> self . __launch . unknown_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> sc_id = leop_utils . generate_object_sc_identifier ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> self . assertTrue ( <EOL> self . __launch . identified_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> tle_id = leop_utils . generate_object_tle_id ( <EOL> self . __ufo_1_id , self . __ufo_1_cs <EOL> ) <EOL> self . assertTrue ( <EOL> tle_models . TwoLineElement . objects . filter ( <EOL> identifier = tle_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertTrue ( <EOL> simulation_models . GroundTrack . objects . filter ( <EOL> spacecraft = segment_models . Spacecraft . objects . get ( <EOL> identifier = sc_id <EOL> ) <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( sc_id ) ) <EOL> print ( '<STR_LIT>' + str ( tle_id ) ) <EOL> def test_forget ( self ) : <EOL> """<STR_LIT>""" <EOL> launch_models . Launch . objects . add_unknown ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> self . assertEqual ( <EOL> len ( simulation_models . GroundTrack . objects . all ( ) ) , <NUM_LIT:2> , <EOL> '<STR_LIT>' <EOL> ) <EOL> launch_models . Launch . objects . identify ( <EOL> self . __launch_id , self . __ufo_1_id , self . __ufo_1_cs , <EOL> self . __tle_l1 , self . __tle_l2 <EOL> ) <EOL> self . assertFalse ( <EOL> self . __launch . unknown_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertTrue ( <EOL> launch_models . Launch . objects . forget ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertTrue ( <EOL> self . __launch . unknown_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> sc_id = leop_utils . generate_object_sc_identifier ( <EOL> self . __launch_id , self . __ufo_1_id <EOL> ) <EOL> self . assertFalse ( <EOL> self . __launch . identified_objects . filter ( <EOL> identifier = self . __ufo_1_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> tle_id = leop_utils . generate_object_tle_id ( <EOL> self . __ufo_1_id , self . __ufo_1_cs <EOL> ) <EOL> self . assertFalse ( <EOL> tle_models . TwoLineElement . objects . filter ( <EOL> identifier = tle_id <EOL> ) . exists ( ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> len ( simulation_models . GroundTrack . objects . all ( ) ) , <NUM_LIT:2> , <EOL> '<STR_LIT>' <EOL> ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( sc_id ) ) <EOL> print ( '<STR_LIT>' + str ( tle_id ) ) </s>
