<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import datetime <EOL> import logging <EOL> from django import test <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 . serializers import rules as rule_serializers <EOL> from services . configuration . jrpc . views import rules as rule_jrpc <EOL> from services . scheduling . models import availability as availability_models <EOL> from services . scheduling . models import operational as operational_models <EOL> class INTRARulesAvailability ( 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> self . __rule_date = misc . get_today_utc ( ) + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> self . __rule_s_time = misc . get_today_utc ( ) . replace ( <EOL> hour = <NUM_LIT:12> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> <EOL> ) <EOL> self . __rule_e_time = self . __rule_s_time + datetime . timedelta ( hours = <NUM_LIT:5> ) <EOL> from services . scheduling . signals import availability <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_rule_created_deleted ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> rule_1_pk = rule_jrpc . add_rule ( <EOL> self . __gs_1_id , <EOL> db_tools . create_jrpc_once_rule ( <EOL> starting_time = self . __rule_s_time , ending_time = self . __rule_e_time <EOL> ) <EOL> ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <EOL> <NUM_LIT:1> , <EOL> '<STR_LIT>' <EOL> ) <EOL> rule_jrpc . remove_rule ( self . __gs_1_id , rule_1_pk ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <EOL> <NUM_LIT:0> , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_multiple_rules ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> rule_1_pk = rule_jrpc . add_rule ( <EOL> self . __gs_1_id , <EOL> db_tools . create_jrpc_once_rule ( <EOL> starting_time = self . __rule_s_time , ending_time = self . __rule_e_time <EOL> ) <EOL> ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:1> <EOL> ) <EOL> rule_2_pk = rule_jrpc . add_rule ( <EOL> self . __gs_1_id , <EOL> db_tools . create_jrpc_once_rule ( <EOL> operation = rule_jrpc . rule_serializers . RULE_OP_REMOVE , <EOL> starting_time = self . __rule_s_time , ending_time = self . __rule_e_time <EOL> ) <EOL> ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:0> <EOL> ) <EOL> rule_jrpc . remove_rule ( self . __gs_1_id , rule_2_pk ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:1> <EOL> ) <EOL> rule_3 = db_tools . create_jrpc_once_rule ( <EOL> operation = rule_serializers . RULE_OP_REMOVE , <EOL> starting_time = self . __rule_s_time , ending_time = self . __rule_e_time <EOL> ) <EOL> rule_3_pk = rule_jrpc . add_rule ( self . __gs_1_id , rule_3 ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:0> <EOL> ) <EOL> rule_jrpc . remove_rule ( self . __gs_1_id , rule_3_pk ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:1> <EOL> ) <EOL> rule_jrpc . remove_rule ( self . __gs_1_id , rule_1_pk ) <EOL> self . assertEquals ( <EOL> availability_models . AvailabilitySlot . objects . count ( ) , <NUM_LIT:0> <EOL> ) </s>
