<s> import datetime <EOL> from django import test as django_test <EOL> from django . db . models import Q <EOL> from services . common import misc as sn_misc <EOL> from services . common import 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 . scheduling . models import operational as operational_models <EOL> from services . scheduling . jrpc . views . operational import slots as scheduling_slots <EOL> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class JRPCBookingProcessTest ( django_test . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __verbose_testing = False <EOL> self . __test_slot_id = - <NUM_LIT:1> <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_f = <NUM_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 . __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> self . __sc_1_ch_1 = db_tools . sc_add_channel ( <EOL> self . __sc_1 , self . __sc_1_ch_1_f , self . __sc_1_ch_1_id , <EOL> ) <EOL> self . __gs_1_ch_1 = db_tools . gs_add_channel ( <EOL> self . __gs_1 , self . __band , self . __gs_1_ch_1_id <EOL> ) <EOL> self . __rule_1 = jrpc_rules . add_rule ( <EOL> self . __gs_1_id , <EOL> db_tools . create_jrpc_daily_rule ( <EOL> date_i = sn_misc . get_today_utc ( ) , <EOL> date_f = sn_misc . get_today_utc ( ) + datetime . timedelta ( days = <NUM_LIT:50> ) , <EOL> starting_time = sn_misc . get_next_midnight ( ) + datetime . timedelta ( <EOL> seconds = <NUM_LIT:1> <EOL> ) , <EOL> ending_time = sn_misc . get_next_midnight ( ) + datetime . timedelta ( <EOL> hours = <NUM_LIT> , minutes = <NUM_LIT> , seconds = <NUM_LIT> <EOL> ) <EOL> ) <EOL> ) <EOL> def test_test_slot ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> s_time = sn_misc . get_now_utc ( no_microseconds = True ) <EOL> e_time = s_time + datetime . timedelta ( hours = <NUM_LIT:2> ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( s_time . isoformat ( ) ) ) <EOL> print ( '<STR_LIT>' + str ( e_time . isoformat ( ) ) ) <EOL> self . assertEquals ( <EOL> scheduling_slots . get_slot ( self . __test_slot_id ) , { <EOL> '<STR_LIT:state>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : s_time . isoformat ( ) , <EOL> '<STR_LIT>' : e_time . isoformat ( ) <EOL> } <EOL> ) <EOL> def test_get_next_slot ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> self . assertEquals ( scheduling_slots . get_next_slot ( '<STR_LIT>' ) , { } ) <EOL> self . assertIsNotNone ( scheduling_slots . get_next_slot ( '<STR_LIT>' ) ) </s>
