<s> import datetime <EOL> import logging <EOL> from django import test <EOL> from django . db import models <EOL> from services . common import misc , helpers as db_tools <EOL> from services . configuration . jrpc . serializers import channels as channel_serializers <EOL> from services . configuration . jrpc . views import rules as jrpc_rules <EOL> from services . configuration . jrpc . views . channels import groundstations as jrpc_gs_ch_if <EOL> from services . configuration . jrpc . views . channels import spacecraft as jrpc_sc_ch_if <EOL> from services . scheduling . jrpc . views . operational import groundstations as jrpc_gs_scheduling <EOL> from services . scheduling . models import availability as availability_models <EOL> from services . scheduling . models import compatibility as compatibility_models <EOL> from services . scheduling . models import operational as operational_models <EOL> from services . simulation . models import passes as pass_models <EOL> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class JRPCGroundStationsSchedulingTest ( 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 . __sc_1_id = '<STR_LIT>' <EOL> self . __sc_1_tle_id = '<STR_LIT>' <EOL> self . __sc_1_ch_1_id = '<STR_LIT>' <EOL> self . __sc_1_ch_1_cfg = { <EOL> channel_serializers . FREQUENCY_K : '<STR_LIT>' , <EOL> channel_serializers . MODULATION_K : '<STR_LIT>' , <EOL> channel_serializers . POLARIZATION_K : '<STR_LIT>' , <EOL> channel_serializers . BITRATE_K : '<STR_LIT>' , <EOL> channel_serializers . BANDWIDTH_K : '<STR_LIT>' <EOL> } <EOL> self . __gs_1_id = '<STR_LIT>' <EOL> self . __gs_1_ch_1_id = '<STR_LIT>' <EOL> self . __gs_1_ch_1_cfg = { <EOL> channel_serializers . BAND_K : <EOL> '<STR_LIT>' , <EOL> channel_serializers . AUTOMATED_K : False , <EOL> channel_serializers . MODULATIONS_K : [ '<STR_LIT>' ] , <EOL> channel_serializers . POLARIZATIONS_K : [ '<STR_LIT>' ] , <EOL> channel_serializers . BITRATES_K : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> channel_serializers . BANDWIDTHS_K : [ <NUM_LIT> , <NUM_LIT> ] <EOL> } <EOL> self . __gs_1_ch_2_id = '<STR_LIT>' <EOL> self . __gs_1_ch_2_cfg = { <EOL> channel_serializers . BAND_K : <EOL> '<STR_LIT>' , <EOL> channel_serializers . AUTOMATED_K : False , <EOL> channel_serializers . MODULATIONS_K : [ '<STR_LIT>' ] , <EOL> channel_serializers . POLARIZATIONS_K : [ '<STR_LIT>' ] , <EOL> channel_serializers . BITRATES_K : [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> channel_serializers . BANDWIDTHS_K : [ <NUM_LIT> , <NUM_LIT> ] <EOL> } <EOL> from services . scheduling . signals import availability <EOL> from services . scheduling . signals import compatibility <EOL> from services . scheduling . signals import operational <EOL> self . __band = db_tools . create_band ( ) <EOL> self . __user_profile = db_tools . create_user_profile ( ) <EOL> self . __sc_1 = db_tools . create_sc ( <EOL> user_profile = self . __user_profile , <EOL> identifier = self . __sc_1_id , <EOL> tle_id = self . __sc_1_tle_id , <EOL> ) <EOL> self . __gs_1 = db_tools . create_gs ( <EOL> user_profile = self . __user_profile , identifier = self . __gs_1_id , <EOL> ) <EOL> operational_models . OperationalSlot . objects . set_debug ( ) <EOL> def test_gs_get_operational_slots ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> self . maxDiff = None <EOL> operational_models . OperationalSlot . objects . reset_ids_counter ( ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> misc . print_list ( <EOL> availability_models . AvailabilitySlot . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> compatibility_models . ChannelCompatibility . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> pass_models . PassSlots . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> operational_models . OperationalSlot . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> self . assertRaises ( <EOL> models . ObjectDoesNotExist , <EOL> jrpc_gs_scheduling . get_operational_slots , <EOL> <NUM_LIT:0> <EOL> ) <EOL> self . assertTrue ( <EOL> jrpc_gs_ch_if . gs_channel_create ( <EOL> groundstation_id = self . __gs_1_id , <EOL> channel_id = self . __gs_1_ch_1_id , <EOL> configuration = self . __gs_1_ch_1_cfg <EOL> ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertRaises ( <EOL> Exception , <EOL> jrpc_gs_scheduling . get_operational_slots , <EOL> self . __gs_1_ch_1_id <EOL> ) <EOL> self . assertTrue ( <EOL> jrpc_sc_ch_if . sc_channel_create ( <EOL> spacecraft_id = self . __sc_1_id , <EOL> channel_id = self . __sc_1_ch_1_id , <EOL> configuration = self . __sc_1_ch_1_cfg <EOL> ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> date_i = misc . get_today_utc ( ) + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> date_f = misc . get_today_utc ( ) + datetime . timedelta ( days = <NUM_LIT> ) <EOL> s_time = misc . get_next_midnight ( ) - datetime . timedelta ( hours = <NUM_LIT:20> ) <EOL> e_time = s_time + datetime . timedelta ( hours = <NUM_LIT:12> ) <EOL> jrpc_rules . add_rule ( <EOL> self . __gs_1_id , <EOL> db_tools . create_jrpc_daily_rule ( <EOL> date_i = date_i , <EOL> date_f = date_f , <EOL> starting_time = s_time , <EOL> ending_time = e_time <EOL> ) <EOL> ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> misc . print_list ( <EOL> availability_models . AvailabilitySlot . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> compatibility_models . ChannelCompatibility . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> pass_models . PassSlots . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> misc . print_list ( <EOL> operational_models . OperationalSlot . objects . all ( ) , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> self . assertGreater ( <EOL> len ( jrpc_gs_scheduling . get_operational_slots ( self . __gs_1_id ) ) , <NUM_LIT:0> <EOL> ) <EOL> self . assertTrue ( <EOL> jrpc_gs_ch_if . gs_channel_delete ( <EOL> groundstation_id = self . __gs_1_id , channel_id = self . __gs_1_ch_1_id <EOL> ) , <EOL> '<STR_LIT>' + str ( <EOL> self . __gs_1_ch_1_id <EOL> ) <EOL> ) <EOL> self . assertEquals ( <EOL> len ( jrpc_gs_scheduling . get_operational_slots ( self . __gs_1_id ) ) , <NUM_LIT:0> <EOL> ) <EOL> self . assertTrue ( <EOL> jrpc_sc_ch_if . sc_channel_delete ( <EOL> spacecraft_id = self . __sc_1_id , channel_id = self . __sc_1_ch_1_id <EOL> ) <EOL> ) <EOL> self . assertEquals ( <EOL> len ( jrpc_gs_scheduling . get_operational_slots ( self . __gs_1_id ) ) , <NUM_LIT:0> <EOL> ) </s>
