def test_compatibility_case_4(self): """INTR test: services.scheduling - basic MIXED compatibility test (2) (CHANGE-1) +SC_CH (CHANGE-2) +GS_CH (Compatible) (CHECK-1) len(SegmentCompatibility) = 1 (CHANGE-3) -SC_CH (CHECK-2) len(SegmentCompatibility) = 0 (CHANGE-4) +SC_CH (Compatible) (CHECK-3) len(SegmentCompatibility) = 1 (CHANGE-5) -GS_CH (CHECK-3) len(SegmentCompatibility) = 0 """ if self.__verbose_testing: print('##### test_compatibility_case_4') # (CHANGE-1) db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-2) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, ) # (CHECK-1) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-3) db_tools.remove_sc_channel(self.__sc_1_ch_1_id) # (CHECK-2) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) # (CHANGE-4) db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHECK-3) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-5) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_1_id) # (CHECK-4) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) # Unchecked change, just for cleaning the database. db_tools.remove_sc_channel(self.__sc_1_ch_1_id)
def test_compatibility_case_3(self): """INTR test: services.scheduling - basic MIXED compatibility test (1) (CHANGE-1) +SC_CH (CHANGE-2) +GS_CH (Non compatible) (CHECK-1) len(SegmentCompatibility) = 0 (CHANGE-3) -SC_CH (CHECK-2) len(SegmentCompatibility) = 0 (CHANGE-4) +SC_CH (Non compatible) (CHANGE-5) -GS_CH (CHECK-3) len(SegmentCompatibility) = 0 """ if self.__verbose_testing: print('##### test_compatibility_case_3') # (CHANGE-1) db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-2) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, polarizations=[ band_models.AvailablePolarizations.objects.get( polarization='LHCP' ) ] ) # (CHECK-1) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) # (CHANGE-3) db_tools.remove_sc_channel(self.__sc_1_ch_1_id) # (CHECK-2) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) # (CHANGE-4) db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-5) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_1_id) # (CHECK-3) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) # Unchecked change, just for cleaning the database. db_tools.remove_sc_channel(self.__sc_1_ch_1_id)
def setUp(self): self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('scheduling').setLevel(level=logging.CRITICAL) logging.getLogger('configuration').setLevel(level=logging.CRITICAL) self.__gs_1_id = 'uvigo' self.__gs_1_ch_1_id = 'qpsk-gs-1' self.__sc_1_id = 'xatcobe-sc' self.__sc_1_tle_id = 'HUMSAT-D' self.__sc_1_ch_1_id = 'qpsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__band = db_tools.create_band() self.__test_user_profile = db_tools.create_user_profile() self.__simulator = simulation.OrbitalSimulator() self.__gs_1 = db_tools.create_gs( user_profile=self.__test_user_profile, identifier=self.__gs_1_id, contact_elevation=0, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__sc_1 = db_tools.create_sc( user_profile=self.__test_user_profile, identifier=self.__sc_1_id, tle_id=self.__sc_1_tle_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def setUp(self): self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) logging.getLogger('simulation').setLevel(level=logging.CRITICAL) self.__gs_1_id = 'gs-castrelos' self.__gs_1_ch_1_id = 'chan-cas-1' self.__sc_1_id = 'sc-xatcobeo' self.__sc_1_ch_1_id = 'xatco-fm-1' self.__sc_1_ch_1_f = 437000000 from services.configuration.signals import tle from services.scheduling.signals import compatibility from services.scheduling.signals import availability self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def setUp(self): """ This method populates the database with some information to be used only for this test. """ self.__verbose_testing = False self.__test_slot_id = -1 self.__sc_1_id = 'xatcobeo-sc' self.__sc_1_tle_id = 'HUMSAT-D' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_1_cfg = { channel_serializers.FREQUENCY_K: '437000000', channel_serializers.MODULATION_K: 'FM', channel_serializers.POLARIZATION_K: 'LHCP', channel_serializers.BITRATE_K: '300', channel_serializers.BANDWIDTH_K: '12.500000000' } self.__gs_1_id = 'gs-la' self.__gs_1_ch_1_id = 'gs-la-fm' self.__gs_1_ch_1_cfg = { channel_serializers.BAND_K: 'UHF / U / 435000000.000000 / 438000000.000000', channel_serializers.AUTOMATED_K: False, channel_serializers.MODULATIONS_K: ['FM'], channel_serializers.POLARIZATIONS_K: ['LHCP'], channel_serializers.BITRATES_K: [300, 600, 900], channel_serializers.BANDWIDTHS_K: [12.500000000, 25.000000000] } self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id, tle_id=self.__sc_1_tle_id, ) self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel(self.__gs_1, self.__band, self.__gs_1_ch_1_id) self.__rule_1 = jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=sn_misc.get_today_utc(), date_f=sn_misc.get_today_utc() + datetime.timedelta(days=50), starting_time=sn_misc.get_next_midnight() + datetime.timedelta(seconds=1), ending_time=sn_misc.get_next_midnight() + datetime.timedelta(hours=23, minutes=59, seconds=59)))
def test_gs_channel_update_compatibility(self): """INTR test: services.scheduling - compatibility diff """ if self.__verbose_testing: print('##### test_compatibility_case_6') # (CHANGE-1) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-2) self.__sc_1_ch_2 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_2_id, ) # (CHANGE-3) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, ) # (CHANGE-4) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_2_id, ) # 1) by default, no new channels if there is no changes gs_ch = channel_models.GroundStationChannel.objects.get( identifier=self.__gs_1_ch_1_id ) c1 = jrpc_compat_if.sc_get_compatible(self.__sc_1_id) self.assertEquals(len(c1['Compatibility'][0]['Compatibility']), 2) # 2) changing the polarization should make the GS_CH incompatible gs_ch.polarizations.clear() gs_ch.polarizations.add( band_models.AvailablePolarizations.objects.get(polarization='LHCP') ) gs_ch.save() c2 = jrpc_compat_if.sc_get_compatible(self.__sc_1_id) self.assertEquals(len(c2['Compatibility'][0]['Compatibility']), 1) # 3) changing it to the original configuration gs_ch.polarizations.add( band_models.AvailablePolarizations.objects.get(polarization='RHCP') ) gs_ch.save() c3 = jrpc_compat_if.sc_get_compatible(self.__sc_1_id) self.assertEquals(len(c3['Compatibility'][0]['Compatibility']), 2)
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) self.__gs_id = 'uvigo' self.__gs_ch_1_id = 'qpsk-gs-1' self.__gs_ch_2_id = 'qpsk-gs-2' self.__sc_id = 'humd' self.__sc_ch_1_id = 'gmsk-sc-1' self.__sc_ch_f = 437000000 self.__sc_ch_2_id = 'gmsk-sc-2' self.__sc_id = 'beesat' self.__band = db_tools.create_band() self.__test_user_profile = db_tools.create_user_profile() self.__gs = db_tools.create_gs( user_profile=self.__test_user_profile, identifier=self.__gs_id, ) self.__gs_ch_1 = db_tools.gs_add_channel(self.__gs, self.__band, self.__gs_ch_1_id) self.__gs_ch_2 = db_tools.gs_add_channel(self.__gs, self.__band, self.__gs_ch_2_id) self.__sc = db_tools.create_sc(user_profile=self.__test_user_profile, identifier=self.__sc_id) self.__sc_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_ch_f, self.__sc_ch_1_id, ) self.__sc_ch_2 = db_tools.sc_add_channel( self.__sc, self.__sc_ch_f, self.__sc_ch_2_id, )
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) self.__gs_id = 'uvigo' self.__gs_ch_1_id = 'qpsk-gs-1' self.__gs_ch_2_id = 'qpsk-gs-2' self.__sc_id = 'humd' self.__sc_ch_1_id = 'gmsk-sc-1' self.__sc_ch_f = 437000000 self.__sc_ch_2_id = 'gmsk-sc-2' self.__sc_id = 'beesat' self.__band = db_tools.create_band() self.__test_user_profile = db_tools.create_user_profile() self.__gs = db_tools.create_gs( user_profile=self.__test_user_profile, identifier=self.__gs_id, ) self.__gs_ch_1 = db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_ch_1_id ) self.__gs_ch_2 = db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_ch_2_id ) self.__sc = db_tools.create_sc( user_profile=self.__test_user_profile, identifier=self.__sc_id ) self.__sc_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_ch_f, self.__sc_ch_1_id, ) self.__sc_ch_2 = db_tools.sc_add_channel( self.__sc, self.__sc_ch_f, self.__sc_ch_2_id, )
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) logging.getLogger('scheduling').setLevel(level=logging.CRITICAL) logging.getLogger('simulation').setLevel(level=logging.CRITICAL) # noinspection PyUnresolvedReferences from services.scheduling.signals import compatibility self.__gs_1_id = 'uvigo' self.__gs_1_ch_1_id = 'qpsk-gs-1' self.__gs_1_ch_2_id = 'qpsk-gs-2' self.__gs_2_id = 'calpoly' self.__sc_1_id = 'humd' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_2_id = 'gmsk-sc-2' self.__sc_2_id = 'beesat' self.__band = db_tools.create_band() self.__test_user_profile = db_tools.create_user_profile() self.__gs_1 = db_tools.create_gs( user_profile=self.__test_user_profile, identifier=self.__gs_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__gs_2 = db_tools.create_gs( user_profile=self.__test_user_profile, identifier=self.__gs_2_id, ) self.__sc_1 = db_tools.create_sc( user_profile=self.__test_user_profile, identifier=self.__sc_1_id ) self.__sc_2 = db_tools.create_sc( user_profile=self.__test_user_profile, identifier=self.__sc_2_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def test_compatibility_case_1(self): """INTR test: services.scheduling - basic SC_CH compatibility test (1) (CHANGE-1) +SC_CH (CHECK-1) len(SegmentCompatibility) = 0 (CHANGE-2) -SC_CH (CHECK-2) len(SegmentCompatibility) = 0 """ if self.__verbose_testing: print('##### test_compatibility_case_1') db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' ) db_tools.remove_sc_channel(self.__sc_1_ch_1_id) self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must be empty!' )
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = False if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) # noinspection PyUnresolvedReferences from services.scheduling.signals import compatibility self.__gs_1_id = 'gs-castrelos' self.__gs_1_ch_1_id = 'chan-cas-1' self.__gs_1_ch_2_id = 'chan-cas-2' self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__gs_1_ch_2 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_2_id ) self.__sc_1_id = 'humd' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_2_id = 'gmsk-sc-2' self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = True if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) logging.getLogger('django.db.backends.schema')\ .setLevel(level=logging.CRITICAL) self.__gs_1_id = 'gs-castrelos' self.__gs_1_ch_1_id = 'chan-cas-1' self.__gs_1_ch_2_id = 'chan-cas-2' self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__gs_1_ch_2 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_2_id ) self.__sc_1_id = 'humd' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_2_id = 'gmsk-sc-2' self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def setUp(self): """ Populates the initial database with a set of objects required to run the following tests. """ self.__verbose_testing = True if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) logging.getLogger('django.db.backends.schema')\ .setLevel(level=logging.CRITICAL) self.__gs_1_id = 'gs-castrelos' self.__gs_1_ch_1_id = 'chan-cas-1' self.__gs_1_ch_2_id = 'chan-cas-2' self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel(self.__gs_1, self.__band, self.__gs_1_ch_1_id) self.__gs_1_ch_2 = db_tools.gs_add_channel(self.__gs_1, self.__band, self.__gs_1_ch_2_id) self.__sc_1_id = 'humd' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_2_id = 'gmsk-sc-2' self.__sc_1 = db_tools.create_sc(user_profile=self.__user_profile, identifier=self.__sc_1_id) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, )
def test_compatibility_case_6(self): """INTR test: services.scheduling - complex MIXED compatibility test (2) (CHANGE-1) +SC-1 (CHANGE-2) +SC-2 (CHANGE-3) +GS-1 (SC-1 & SC-2 compatible) (CHANGE-4) +GS-2 (SC-1 & SC-2 compatible) (CHECK-1) len(SegmentCompatibility) = 4 (CHANGE-5) +SC-3 (GS-1 & GS-2 compatible) (CHANGE-6) +SC-4 (GS-1 & GS-2 compatible) (CHECK-2) len(SegmentCompatibility) = 8 (CHANGE-7) -GS-1 (CHECK-3) len(SegmentCompatibility) = 4 (CHANGE-8) -GS-2 (CHECK-4) len(SegmentCompatibility) = 0 """ if self.__verbose_testing: print('##### test_compatibility_case_6') # (CHANGE-1) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-2) self.__sc_1_ch_2 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_2_id, ) # (CHANGE-3) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, ) # (CHANGE-4) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_2_id, ) # >>>>> (CHECK-1) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 4, 'Table must have 4 entr(ies)!' ) # (CHANGE-5) self.__sc_1_ch_3 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_3_id, ) # (CHANGE-6) self.__sc_1_ch_4 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_4_id, ) # >>>>> (CHECK-2) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 8, 'Table must have 8 entr(ies)!' ) # (CHANGE-7) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_1_id) # >>>>> (CHECK-3) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 4, 'Table must have 4 entr(ies)!' ) # (CHANGE-8) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_2_id) # >>>>> (CHECK-4) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must have 0 entr(ies)!' ) # Unchecked change, just for cleaning the database. db_tools.remove_sc_channel(self.__sc_1_ch_1_id) db_tools.remove_sc_channel(self.__sc_1_ch_2_id) db_tools.remove_sc_channel(self.__sc_1_ch_3_id) db_tools.remove_sc_channel(self.__sc_1_ch_4_id)
def test_compatibility_case_5(self): """INTR test: services.scheduling - complex MIXED compatibility test (1) (CHANGE-1) +SC_CH (CHANGE-2) +GS_CH (Compatible) (CHANGE-3) +GS_CH (CHANGE-4) +GS_CH (Compatible) (CHECK-1) len(SegmentCompatibility) = 2 (CHANGE-5) -GS_CH (Compatible) (CHECK-2) len(SegmentCompatibility) = 1 (CHANGE-6) -GS_CH (CHECK-3) len(SegmentCompatibility) = 1 (CHANGE-7) -GS_CH (Compatible) (CHECK-4) len(SegmentCompatibility) = 0 (CHANGE-8) -SC_CH (CHECK-5) len(SegmentCompatibility) = 0 (CHANGE-9) +GS_CH (GS-1) (CHANGE-A) +GS_CH (GS-2) (CHANGE-B) +SC_CH (Compatible with GS-2) (CHECK-6) len(SegmentCompatibility) = 1 (CHANGE-C) -GS_CH (GS-1) (CHECK-7) len(SegmentCompatibility) = 1 (CHANGE-D) +GS_CH (GS-3, Compatible) (CHECK-8) len(SegmentCompatibility) = 2 (CHANGE-E) -SC_CH (CHECK-9) len(SegmentCompatibility) = 0 (CHANGE-F) +SC_CH (Compatible with GS-2 & GS-3) (CHECK-A) len(SegmentCompatibility) = 2 """ if self.__verbose_testing: print('##### test_compatibility_case_5') # (CHANGE-1) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # (CHANGE-2) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, ) # (CHANGE-3) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_2_id, polarizations=[ band_models.AvailablePolarizations.objects.get( polarization='LHCP' ) ] ) # (CHANGE-4) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_3_id, ) # >>>>> (CHECK-1) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 2, 'Table must have 2 entr(ies)!' ) # (CHANGE-5) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_1_id) # >>>>> (CHECK-2) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-6) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_2_id) # >>>>> (CHECK-3) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-7) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_3_id) # >>>>> (CHECK-4) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must have 0 entr(ies)!' ) # (CHANGE-8) db_tools.remove_sc_channel(self.__sc_1_ch_1_id) # >>>>> (CHECK-5) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must have 0 entr(ies)!' ) # (CHANGE-9) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id, polarizations=[ band_models.AvailablePolarizations.objects.get( polarization='LHCP' ) ] ) # (CHANGE-A) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_2_id, ) # (CHANGE-B) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # >>>>> (CHECK-6) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-C) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_1_id) # >>>>> (CHECK-7) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 1, 'Table must have 1 entr(ies)!' ) # (CHANGE-D) db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_3_id, ) # >>>>> (CHECK-8) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 2, 'Table must have 2 entr(ies)!' ) # (CHANGE-E) db_tools.remove_sc_channel(self.__sc_1_ch_1_id) # >>>>> (CHECK-9) <<<<< # self.assertEqual( len(compat_models.ChannelCompatibility.objects.all()), 0, 'Table must have 0 entr(ies)!' ) # (CHANGE-F) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) # >>>>> (CHECK-A) <<<<< # self.assertEqual( compat_models.ChannelCompatibility.objects.filter( spacecraft_channel__identifier=self.__sc_1_ch_1_id ).count(), 2, 'Table must have 2 entr(ies)!' ) # Unchecked change, just for cleaning the database. db_tools.remove_sc_channel(self.__sc_1_ch_1_id) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_2_id) db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_3_id)
def test_bug_1(self): """INTR test: services.scheduling - operational slot generation """ self.__gs_1_id = 'gs-vigo' self.__gs_1_ch_1_id = 'chan-cas-1' self.__sc_1_id = 'sc-serpens' self.__sc_1_ch_1_id = 'xatco-fm-1' self.__sc_1_ch_1_f = 437500000 self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() # 1) create vigo gs self.__gs = db_tools.create_gs(user_profile=self.__user_profile, identifier=self.__gs_1_id) # CHECK A: NO ADDITIONAL pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_0 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id) self.assertEqual(len(p_slots_0), 0) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0) self.assertEqual(len(o_slots_0), 0) # 2) serpens spacecraft self.__sc = db_tools.create_sc(user_profile=self.__user_profile, identifier=self.__sc_1_id) # CHECK B: MORE pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_1 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id) self.assertGreater(len(p_slots_1), len(p_slots_0)) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0) self.assertEqual(len(o_slots_0), 0) # 3) we add channels and, therefore, compatibility matches # without availability rules, no operational slots self.__sc_1_ch_1 = db_tools.sc_add_channel(self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id) self.__gs_1_ch_1 = db_tools.gs_add_channel(self.__gs, self.__band, self.__gs_1_ch_1_id) # CHECK C: SAME pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_2 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id) self.assertEqual(len(p_slots_2), len(p_slots_1)) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0) self.assertEqual(len(o_slots_0), 0) # 4) we add a daily rule 12 hours, 00:00:01am to 11:59:59pm UTC # all pass slots should became operational slots. self.__rule_1 = rules_jrpc.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=sn_misc.get_today_utc(), date_f=sn_misc.get_today_utc() + datetime.timedelta(days=50), starting_time=sn_misc.get_next_midnight() + datetime.timedelta(seconds=1), ending_time=sn_misc.get_next_midnight() + datetime.timedelta(hours=23, minutes=59, seconds=59))) # CHECK D: 3 availability slots (1 per day, almost 24 hours) # should transform all pass slots into operational slots a_slots = availability_models.AvailabilitySlot.objects.values_list( 'start', 'end') x_slots = [ (sn_misc.get_today_utc() + datetime.timedelta(seconds=1), sn_misc.get_today_utc() + datetime.timedelta(hours=23, minutes=59, seconds=59)), (sn_misc.get_today_utc() + datetime.timedelta(days=1, seconds=1), sn_misc.get_today_utc() + datetime.timedelta(days=1, hours=23, minutes=59, seconds=59)), (sn_misc.get_today_utc() + datetime.timedelta(days=2, seconds=1), sn_misc.get_today_utc() + datetime.timedelta(days=2, hours=23, minutes=59, seconds=59)) ] self.assertCountEqual(a_slots, x_slots) p_slots_applicable_objs = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id, start__gte=sn_misc.get_now_utc()) p_slots_applicable = p_slots_applicable_objs.values_list( 'start', 'end') self.assertGreaterEqual(len(p_slots_2), len(p_slots_applicable)) o_slots_1 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_applicable_objs, state=operational_models.STATE_FREE).values_list('start', 'end') self.assertCountEqual(p_slots_applicable, o_slots_1) # CHECK E: RPC interface should return an equivalent set of slots: o_slots_gs = gs_ops_rpc.get_operational_slots(self.__gs_1_id) self.assertEqual(len(o_slots_gs[self.__sc_1_id]), len(o_slots_1)) if self.__verbose_testing: sn_misc.print_list(o_slots_1, name='o_slots_1') sn_misc.print_list(o_slots_gs[self.__sc_1_id], name='o_slots-' + self.__gs_1_id)
def test_bug_1(self): """INTR test: services.scheduling - operational slot generation """ self.__gs_1_id = 'gs-vigo' self.__gs_1_ch_1_id = 'chan-cas-1' self.__sc_1_id = 'sc-serpens' self.__sc_1_ch_1_id = 'xatco-fm-1' self.__sc_1_ch_1_f = 437500000 self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() # 1) create vigo gs self.__gs = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id ) # CHECK A: NO ADDITIONAL pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_0 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id ) self.assertEqual(len(p_slots_0), 0) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0 ) self.assertEqual(len(o_slots_0), 0) # 2) serpens spacecraft self.__sc = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id ) # CHECK B: MORE pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_1 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id ) self.assertGreater(len(p_slots_1), len(p_slots_0)) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0 ) self.assertEqual(len(o_slots_0), 0) # 3) we add channels and, therefore, compatibility matches # without availability rules, no operational slots self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs, self.__band, self.__gs_1_ch_1_id ) # CHECK C: SAME pass slots, no operational slots # ### There are pass slots for the already-propagated spacecraft p_slots_2 = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id ) self.assertEqual(len(p_slots_2), len(p_slots_1)) o_slots_0 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_0 ) self.assertEqual(len(o_slots_0), 0) # 4) we add a daily rule 12 hours, 00:00:01am to 11:59:59pm UTC # all pass slots should became operational slots. self.__rule_1 = rules_jrpc.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=sn_misc.get_today_utc(), date_f=sn_misc.get_today_utc() + datetime.timedelta(days=50), starting_time=sn_misc.get_next_midnight() + datetime.timedelta( seconds=1 ), ending_time=sn_misc.get_next_midnight() + datetime.timedelta( hours=23, minutes=59, seconds=59 ) ) ) # CHECK D: 3 availability slots (1 per day, almost 24 hours) # should transform all pass slots into operational slots a_slots = availability_models.AvailabilitySlot.objects.values_list( 'start', 'end' ) x_slots = [ ( sn_misc.get_today_utc() + datetime.timedelta( seconds=1 ), sn_misc.get_today_utc() + datetime.timedelta( hours=23, minutes=59, seconds=59 ) ), ( sn_misc.get_today_utc() + datetime.timedelta( days=1, seconds=1 ), sn_misc.get_today_utc() + datetime.timedelta( days=1, hours=23, minutes=59, seconds=59 ) ), ( sn_misc.get_today_utc() + datetime.timedelta( days=2, seconds=1 ), sn_misc.get_today_utc() + datetime.timedelta( days=2, hours=23, minutes=59, seconds=59 ) ) ] self.assertCountEqual(a_slots, x_slots) p_slots_applicable_objs = pass_models.PassSlots.objects.filter( groundstation__identifier=self.__gs_1_id, spacecraft__identifier=self.__sc_1_id, start__gte=sn_misc.get_now_utc() ) p_slots_applicable = p_slots_applicable_objs.values_list( 'start', 'end' ) self.assertGreaterEqual(len(p_slots_2), len(p_slots_applicable)) o_slots_1 = operational_models.OperationalSlot.objects.filter( pass_slot__in=p_slots_applicable_objs, state=operational_models.STATE_FREE ).values_list('start', 'end') self.assertCountEqual(p_slots_applicable, o_slots_1) # CHECK E: RPC interface should return an equivalent set of slots: o_slots_gs = gs_ops_rpc.get_operational_slots(self.__gs_1_id) self.assertEqual(len(o_slots_gs[self.__sc_1_id]), len(o_slots_1)) if self.__verbose_testing: sn_misc.print_list(o_slots_1, name='o_slots_1') sn_misc.print_list( o_slots_gs[self.__sc_1_id], name='o_slots-' + self.__gs_1_id )
def setUp(self): """Test setup This method populates the database with some information to be used only for this test. """ self.__verbose_testing = False self.__gs_1_id = 'gs-castrelos' self.__gs_1_callsign = 'GS1GSGS' self.__gs_1_contact_elevation = 10.30 self.__gs_1_longitude = -8.9330 self.__gs_1_latitude = 42.6000 self.__gs_1_configuration = ( self.__gs_1_callsign, 10.3, self.__gs_1_latitude, self.__gs_1_longitude ) self.__gs_2_id = 'gs-calpoly' self.__gs_1_ch_1_id = 'fm-1' self.__gs_1_ch_2_id = 'afsk-2' self.__sc_1_id = 'sc-xatcobeo' self.__sc_1_callsign = 'BABA00' self.__sc_1_tle_id = str('HUMSAT-D') self.__sc_1_ch_1_id = 'xatcobeo-qpsk-1' self.__sc_1_ch_2_id = 'xatcobeo-gmsk-2' self.__sc_1_ch_1_f = 437000000 self.__sc_1_configuration = ( self.__sc_1_callsign, self.__sc_1_tle_id ) self.__sc_2_id = 'sc-swisscube' self.__sc_2_tle_id = str('SWISSCUBE') self.__sc_3_id = 'sc-somp' self.__sc_3_tle_id = str('SOMP') self.__sc_4_id = 'sc-test' self.__sc_4_callsign = 'GOXX5' self.__sc_4_tle_id = 'GOES 4 [-]' self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__http_request = db_tools.create_request( user_profile=self.__user_profile ) self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, callsign=self.__gs_1_callsign, contact_elevation=self.__gs_1_contact_elevation, latitude=self.__gs_1_latitude, longitude=self.__gs_1_longitude, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id, ) self.__gs_2 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_2_id ) self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id, callsign=self.__sc_1_callsign, tle_id=self.__sc_1_tle_id ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) self.__sc_2 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_2_id, tle_id=self.__sc_2_tle_id ) if not self.__verbose_testing: logging.getLogger('configuration').setLevel(level=logging.CRITICAL) logging.getLogger('simulation').setLevel(level=logging.CRITICAL) logging.getLogger('common').setLevel(level=logging.CRITICAL)
def setUp(self): """ This method populates the database with some information to be used only for this test. """ self.__verbose_testing = False self.__test_slot_id = -1 self.__sc_1_id = 'xatcobeo-sc' self.__sc_1_tle_id = 'HUMSAT-D' self.__sc_1_ch_1_id = 'gmsk-sc-1' self.__sc_1_ch_1_f = 437000000 self.__sc_1_ch_1_cfg = { channel_serializers.FREQUENCY_K: '437000000', channel_serializers.MODULATION_K: 'FM', channel_serializers.POLARIZATION_K: 'LHCP', channel_serializers.BITRATE_K: '300', channel_serializers.BANDWIDTH_K: '12.500000000' } self.__gs_1_id = 'gs-la' self.__gs_1_ch_1_id = 'gs-la-fm' self.__gs_1_ch_1_cfg = { channel_serializers.BAND_K: 'UHF / U / 435000000.000000 / 438000000.000000', channel_serializers.AUTOMATED_K: False, channel_serializers.MODULATIONS_K: ['FM'], channel_serializers.POLARIZATIONS_K: ['LHCP'], channel_serializers.BITRATES_K: [300, 600, 900], channel_serializers.BANDWIDTHS_K: [12.500000000, 25.000000000] } self.__band = db_tools.create_band() self.__user_profile = db_tools.create_user_profile() self.__sc_1 = db_tools.create_sc( user_profile=self.__user_profile, identifier=self.__sc_1_id, tle_id=self.__sc_1_tle_id, ) self.__gs_1 = db_tools.create_gs( user_profile=self.__user_profile, identifier=self.__gs_1_id, ) self.__sc_1_ch_1 = db_tools.sc_add_channel( self.__sc_1, self.__sc_1_ch_1_f, self.__sc_1_ch_1_id, ) self.__gs_1_ch_1 = db_tools.gs_add_channel( self.__gs_1, self.__band, self.__gs_1_ch_1_id ) self.__rule_1 = jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=sn_misc.get_today_utc(), date_f=sn_misc.get_today_utc() + datetime.timedelta(days=50), starting_time=sn_misc.get_next_midnight() + datetime.timedelta( seconds=1 ), ending_time=sn_misc.get_next_midnight() + datetime.timedelta( hours=23, minutes=59, seconds=59 ) ) )