def test_get_groundtrack(self): """JRPC test: services.simulation.groundtrack.get Tests the generation of the GroundTracks for registered spacecraft. """ gt = simulation_jrpc.get_groundtrack(self.__sc_1_id) if self.__verbose_testing: misc.print_list(gt) print('gt.length = ' + str(len(gt)))
def test_normalize_complex_2(self): """UNIT test: services.common.slots.normalize_slots (complex case #2) Case COMPLEX#2 for normalizing slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING NORMALIZE, CASE COMPLEX#2: continuous ABC') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') s = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=1)) t = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=4)) u = (misc.get_today_utc() + timedelta(hours=3), misc.get_today_utc() + timedelta(hours=5)) v = (misc.get_today_utc() + timedelta(hours=4), misc.get_today_utc() + timedelta(hours=4, minutes=10)) expected_s = [s, (t[0], u[1])] actual_s = slots.normalize_slots([s, t, u, v]) if self.__verbose_testing: misc.print_list([s, t, u, v], name='RAW slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual(expected_s, actual_s, 'CASE COMPLEX#1: Wrong result!')
def test_normalize_complex_1(self): """UNIT test: services.common.slots.normalize_slots (complex case #1) Case COMPLEX#1 for normalizing slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING NORMALIZE, CASE COMPLEX#1: ABC') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') s = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=1)) t = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=4)) u = (misc.get_today_utc() + timedelta(hours=5), misc.get_today_utc() + timedelta(hours=7)) v = (misc.get_today_utc() + timedelta(hours=6), misc.get_today_utc() + timedelta(hours=9)) w = (misc.get_today_utc() + timedelta(hours=10), misc.get_today_utc() + timedelta(hours=15)) x = (misc.get_today_utc() + timedelta(hours=11), misc.get_today_utc() + timedelta(hours=14)) expected_s = [s, t, (u[0], v[1]), w] actual_s = slots.normalize_slots([s, t, u, v, w, x]) if self.__verbose_testing: misc.print_list([s, t, u, v, w, x], name='RAW slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual( expected_s, actual_s, 'CASE COMPLEX#1: Wrong result!' )
def test_normalize_complex_2(self): """UNIT test: services.common.slots.normalize_slots (complex case #2) Case COMPLEX#2 for normalizing slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING NORMALIZE, CASE COMPLEX#2: continuous ABC') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') s = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=1)) t = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=4)) u = (misc.get_today_utc() + timedelta(hours=3), misc.get_today_utc() + timedelta(hours=5)) v = (misc.get_today_utc() + timedelta(hours=4), misc.get_today_utc() + timedelta(hours=4, minutes=10)) expected_s = [s, (t[0], u[1])] actual_s = slots.normalize_slots([s, t, u, v]) if self.__verbose_testing: misc.print_list([s, t, u, v], name='RAW slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual( expected_s, actual_s, 'CASE COMPLEX#1: Wrong result!' )
def test_normalize_complex_1(self): """UNIT test: services.common.slots.normalize_slots (complex case #1) Case COMPLEX#1 for normalizing slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING NORMALIZE, CASE COMPLEX#1: ABC') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') s = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=1)) t = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=4)) u = (misc.get_today_utc() + timedelta(hours=5), misc.get_today_utc() + timedelta(hours=7)) v = (misc.get_today_utc() + timedelta(hours=6), misc.get_today_utc() + timedelta(hours=9)) w = (misc.get_today_utc() + timedelta(hours=10), misc.get_today_utc() + timedelta(hours=15)) x = (misc.get_today_utc() + timedelta(hours=11), misc.get_today_utc() + timedelta(hours=14)) expected_s = [s, t, (u[0], v[1]), w] actual_s = slots.normalize_slots([s, t, u, v, w, x]) if self.__verbose_testing: misc.print_list([s, t, u, v, w, x], name='RAW slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual(expected_s, actual_s, 'CASE COMPLEX#1: Wrong result!')
def test_add_once_rule(self): """JRPC test: (O) cfg.gs.channel.addRule, cfg.gs.channel.removeRule Should correctly add a ONCE rule to the system. """ if self.__verbose_testing: print('>>> TEST (test_gs_channel_add_rule)') # 1) add new rule to the database starting_time = misc.get_next_midnight() - datetime.timedelta(hours=12) ending_time = starting_time + datetime.timedelta(hours=4) rule_cfg = db_tools.create_jrpc_once_rule( starting_time=starting_time, ending_time=ending_time ) rule_id_1 = jrpc_rules.add_rule(self.__gs_1_id, rule_cfg) # 2) get the rule back through the JRPC interface rules_g1c1 = jrpc_rules.list_channel_rules(self.__gs_1_id) expected_r = { jrpc_serial.RULE_PK_K: rule_id_1, jrpc_serial.RULE_PERIODICITY: jrpc_serial.RULE_PERIODICITY_ONCE, jrpc_serial.RULE_OP: jrpc_serial.RULE_OP_ADD, jrpc_serial.RULE_DATES: { jrpc_serial.RULE_ONCE_S_TIME: starting_time.isoformat(), jrpc_serial.RULE_ONCE_E_TIME: ending_time.isoformat() } } if self.__verbose_testing: misc.print_list(rules_g1c1, name='DATABASE') misc.print_dictionary(expected_r) self.assertEqual(rules_g1c1[0], expected_r) jrpc_rules.remove_rule(self.__gs_1_id, rule_id_1) self.__verbose_testing = False
def test_merge_case_complex_3(self): """UNIT test: services.common.slots.merge_slots (complex case #3) """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING MERGE, COMPLEX CASE #3') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') p = (misc.get_today_utc() + timedelta(hours=0), misc.get_today_utc() + timedelta(hours=1)) q = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=3)) r = (misc.get_today_utc() + timedelta(hours=2), misc.get_today_utc() + timedelta(hours=4)) s = (misc.get_today_utc() + timedelta(hours=3), misc.get_today_utc() + timedelta(hours=5)) t = (misc.get_today_utc() + timedelta(hours=6), misc.get_today_utc() + timedelta(hours=7)) u = (misc.get_today_utc() + timedelta(hours=8), misc.get_today_utc() + timedelta(hours=9)) v = (misc.get_today_utc() + timedelta(hours=10), misc.get_today_utc() + timedelta(hours=11)) m = (misc.get_today_utc() + timedelta(hours=0), misc.get_today_utc() + timedelta(hours=3)) n = (misc.get_today_utc() + timedelta(hours=3, minutes=30), misc.get_today_utc() + timedelta(hours=4)) expected_s = [(m[1], n[0]), (s[0], n[0]), (n[1], s[1]), t, u, v] actual_s = slots.merge_slots([p, q, r, s, t, u, v], [m, n]) if self.__verbose_testing: misc.print_list([p, q, r, s], name='(+) slots') misc.print_list([m, n], name='(-) slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual(expected_s, actual_s, 'COMPLEX CASE #1: Wrong result!')
def test_merge_case_c(self): """UNIT test: services.common.slots.merge_slots (case C) Case C for merging slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING MERGE, CASE C') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') p = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=5)) m = (misc.get_today_utc() + timedelta(hours=1), misc.get_today_utc() + timedelta(hours=4)) expected_s = [(p[0], m[0]), (m[1], p[1])] actual_s = slots.merge_slots([p], [m]) if self.__verbose_testing: misc.print_list(p, name='(+) slots') misc.print_list(m, name='(-) slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual(expected_s, actual_s, 'CASE C: Wrong result!')
def test_normalize_c(self): """UNIT test: services.common.slots.normalize_slots (case C) Case C for normalizing slots. """ if self.__verbose_testing: print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') print('TESTING NORMALIZE, CASE C') print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') s = (misc.get_today_utc(), misc.get_today_utc() + timedelta(hours=5)) t = (misc.get_today_utc() + timedelta(hours=1), misc.get_today_utc() + timedelta(hours=4)) expected_s = [s] actual_s = slots.normalize_slots([s, t]) if self.__verbose_testing: misc.print_list([s, t], name='RAW slots') misc.print_list(actual_s, name='(A) slots') misc.print_list(expected_s, name='(EXPECTED) slots') self.assertCountEqual(expected_s, actual_s, 'CASE C: Wrong result!')
def test_utc_database(self): """UNIT test: UTC database datetimes This test validates whether the date/time information saved in the database is converted to UTC or not. """ if self.__verbose_testing: print('>>> test_utc_database:') local_dt = datetime.datetime.now(pytz.timezone('US/Pacific')).replace( hour=0, minute=0, second=0, microsecond=0) utc_dt = datetime.datetime.now(pytz.timezone('UTC')).replace( hour=0, minute=0, second=0, microsecond=0) if self.__verbose_testing: print('>> local_dt = ' + str(local_dt)) print('>> local_dt.iso() = ' + str(local_dt.isoformat())) print('>> local_dt.date() = ' + str(local_dt.date())) print('>> local_dt.time() = ' + str(local_dt.time())) print('>> local_dt.time().iso() = ' + str(local_dt.time().isoformat())) print('>> local_dt.timetz() = ' + str(local_dt.timetz())) print('>> local_dt.tzname() = ' + str(local_dt.tzname())) print('>> local_dt.utcoffset() = ' + str(local_dt.utcoffset())) print('>> utc_dt = ' + str(utc_dt)) print('>> utc_dt.iso() = ' + str(utc_dt.isoformat())) print('>> utc_dt.date() = ' + str(utc_dt.date())) print('>> utc_dt.time() = ' + str(utc_dt.time())) print('>> utc_dt.timetz() = ' + str(utc_dt.timetz())) print('>> utc_dt.tzname() = ' + str(utc_dt.tzname())) # 1) adds a single UTC rule to the database utc_i_date = utc_dt + datetime.timedelta(days=1) utc_e_date = utc_dt + datetime.timedelta(days=366) utc_s_time = utc_dt - datetime.timedelta(minutes=15) utc_e_time = utc_dt + datetime.timedelta(minutes=15) jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule(date_i=utc_i_date, date_f=utc_e_date, starting_time=utc_s_time, ending_time=utc_e_time)) actual = [str(r) for r in rules.AvailabilityRule.objects.all()] expected = [ '+(D):' + utc_i_date.isoformat().split('T')[0] + '>>' + utc_e_date.isoformat().split('T')[0] + '_T_' + utc_s_time.isoformat() + '>>' + utc_e_time.isoformat() ] self.assertEqual(actual, expected) # 2) adds a single PacificTime rule to the database (should be # converted into a UTC one). local_i_date = local_dt local_e_date = local_dt + datetime.timedelta(days=365) local_s_time = local_dt.replace( hour=0, minute=0, second=0, microsecond=0) + datetime.timedelta(hours=12) local_e_time = local_s_time + datetime.timedelta(minutes=30) jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule(date_i=local_i_date, date_f=local_e_date, starting_time=local_s_time, ending_time=local_e_time)) if self.__verbose_testing: print('>>> window = ' + str(simulation.OrbitalSimulator.get_simulation_window())) misc.print_list(rules.AvailabilityRule.objects.all(), name='RULES') actual = [str(r) for r in rules.AvailabilityRule.objects.all()] expected.append('+(D):' + local_i_date.isoformat().split('T')[0] + '>>' + local_e_date.isoformat().split('T')[0] + '_T_' + local_s_time.astimezone(pytz.utc).isoformat() + '>>' + local_e_time.astimezone(pytz.utc).isoformat()) self.assertEqual(actual, expected) if self.__verbose_testing: misc.print_list(availability.AvailabilitySlot.objects.all(), name='Availability Slots')
def _test_4_get_availability_slots(self): """INTR test: services.scheduling - availability slot generation (4) Validates the method that gathers the AvailabilitySlots that are applicable within a defined interval. """ if self.__verbose_testing: print('##### test_get_availability_slots:') # 0) Stability with None... self.assertEqual( availability.AvailabilitySlot.objects.get_applicable(None), [], '[] should be the result!' ) # 1) Stability with []... self.assertEqual( availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, ), [], '[] should be the result!' ) # 2) Single daily rule, adds availability slots... jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=self.__utc_s_date, date_f=self.__utc_e_date, starting_time=self.__utc_s_time, ending_time=self.__utc_e_time ) ) a_slots = list( availability.AvailabilitySlot.objects.values_list( 'start', 'end' ) ) # ### the identifier is included as it is obtained from the actual # ### execution of the method x_slots = [ ( self.__rule_s_time, self.__rule_e_time ), ( self.__rule_s_time + datetime.timedelta(days=1), self.__rule_e_time + datetime.timedelta(days=1) ), ( self.__rule_s_time + datetime.timedelta(days=2), self.__rule_e_time + datetime.timedelta(days=2) ) ] if self.__verbose_testing: print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@1' ) misc.print_list(a_slots, name='AVAILABLE@1') self.assertEqual(a_slots, x_slots) # 3) Period ending in the middle of an AvailabilitySlot, should # return the applicable half of that slot... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time, end=self.__rule_s_time + datetime.timedelta(hours=3) ) x_slots = [ ( self.__rule_s_time, self.__rule_s_time + datetime.timedelta(hours=3), a_slots[0][2] ) ] if self.__verbose_testing: print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list(x_slots, name='XSLOTS@2') misc.print_list(a_slots, name='AVAILABLE@2') self.assertEqual(a_slots, x_slots) # 4) Period starting in the middle of an AvailabilitySlot, should # return the applicable half of that slot... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time + datetime.timedelta(hours=2), end=self.__rule_s_time + datetime.timedelta(hours=8) ) x_slots = [( ( self.__rule_s_time + datetime.timedelta(hours=2), self.__rule_s_time + datetime.timedelta(hours=5), a_slots[0][2] ) )] self.assertEqual(a_slots, x_slots) # 5) Period starting after an AvailabilitySlot, should not return any # slot at all... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time + datetime.timedelta(hours=8), end=self.__rule_s_time + datetime.timedelta(hours=10) ) self.assertEqual(a_slots, []) # 6) Period starting JUST after an AvailabilitySlot, should not return # any slot at all... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time + datetime.timedelta(hours=5), end=self.__rule_s_time + datetime.timedelta(hours=8) ) self.assertEqual(a_slots, []) # 7) Period starting after an AvailabilitySlot, should not return any # slot at all... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time + datetime.timedelta(hours=7), end=self.__rule_s_time + datetime.timedelta(hours=8) ) self.assertEqual(a_slots, []) # 8) Period starting JUST before an AvailabilitySlot, should not return # any slot at all... a_slots = availability.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs, start=self.__rule_s_time - datetime.timedelta(hours=2), end=self.__rule_s_time - datetime.timedelta(hours=1) ) self.assertEqual(a_slots, [])
def _test_3_generate_slots_several_rules_1(self): """INTR test: services.scheduling - add slots with several rules (3) This method tests the addition of new availability slots when there are several availability rules in the database. """ if self.__verbose_testing: print('##### test_add_slots: several rules (1)') # R1) ADD+ONCE (+1 slot) rule_1_id = jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_once_rule( starting_time=self.__rule_s_time, ending_time=self.__rule_e_time ) ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) self.assertEqual( len(a_slots), 1, 'Only 1 slot expected, got = ' + str(len(a_slots)) ) av_slots = availability.AvailabilitySlot.objects.all() self.assertEqual( len(av_slots), 1, '1 slot expected, got = ' + str(len(av_slots)) ) if self.__verbose_testing: misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@1' ) misc.print_list(av_slots, name='AVAILABLE@1') # R2) ADD+DAILY (+2 slots) rule_2_id = jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=self.__utc_s_date, date_f=self.__utc_e_date, starting_time=self.__utc_s_time, ending_time=self.__utc_e_time ) ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) av_slots = availability.AvailabilitySlot.objects.all() if self.__verbose_testing: print('>>> today_utc = ' + str(misc.get_today_utc())) print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@2' ) misc.print_list(av_slots, name='AVAILABLE@2') expected_slots = 3 self.assertEqual(len(a_slots), expected_slots) self.assertEqual(len(av_slots), expected_slots) # R3) ADD-ONCE (-1 slot) rule_3_id = jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_once_rule( operation=jrpc_serial.RULE_OP_REMOVE, starting_time=self.__rule_s_time, ending_time=self.__rule_e_time ) ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) av_slots = availability.AvailabilitySlot.objects.all() if self.__verbose_testing: print('>>> today_utc = ' + str(misc.get_today_utc())) print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@3' ) misc.print_list(av_slots, name='AVAILABLE@3') expected_slots = 2 self.assertEqual(len(a_slots), expected_slots) self.assertEqual(len(av_slots), expected_slots) # R4) ADD-DAILY (-7 slots) rule_4_id = jrpc_rules_if.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( operation=jrpc_serial.RULE_OP_REMOVE, date_i=self.__utc_s_date, date_f=self.__utc_e_date, starting_time=self.__utc_s_time, ending_time=self.__utc_e_time ) ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) av_slots = availability.AvailabilitySlot.objects.all() if self.__verbose_testing: print('>>> today_utc = ' + str(misc.get_today_utc())) print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@4' ) misc.print_list(av_slots, name='AVAILABLE@4') expected = 0 self.assertEqual(len(a_slots), expected) self.assertEqual(len(av_slots), expected) # REMOVE R#4 (+6 slots) jrpc_rules_if.remove_rule( groundstation_id=self.__gs_1_id, rule_id=rule_4_id ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) av_slots = availability.AvailabilitySlot.objects.all() if self.__verbose_testing: print('>>> today_utc = ' + str(misc.get_today_utc())) print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@5' ) misc.print_list(av_slots, name='AVAILABLE@5') expected = 2 self.assertEqual(len(a_slots), expected) self.assertEqual(len(av_slots), expected) # REMOVE R#3 (+1 slot) jrpc_rules_if.remove_rule( groundstation_id=self.__gs_1_id, rule_id=rule_3_id ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) av_slots = availability.AvailabilitySlot.objects.all() if self.__verbose_testing: print('>>> today_utc = ' + str(misc.get_today_utc())) print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@6' ) misc.print_list(av_slots, name='AVAILABLE@6') expected = 3 self.assertEqual(len(a_slots), expected) self.assertEqual(len(av_slots), expected) # REMOVE R#2 (-7 slots) jrpc_rules_if.remove_rule( groundstation_id=self.__gs_1_id, rule_id=rule_2_id ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) self.assertEqual(len(a_slots), 1) av_slots = availability.AvailabilitySlot.objects.all() self.assertEqual(len(av_slots), 1) if self.__verbose_testing: misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@7' ) misc.print_list(av_slots, name='AVAILABLE@7') # REMOVE R#1 (-1 slot) jrpc_rules_if.remove_rule( groundstation_id=self.__gs_1_id, rule_id=rule_1_id ) a_slots = rule_models.AvailabilityRule.objects.get_availability_slots( self.__gs ) self.assertEqual(len(a_slots), 0) av_slots = availability.AvailabilitySlot.objects.all() self.assertEqual(len(av_slots), 0) if self.__verbose_testing: misc.print_list( rule_models.AvailabilityRule.objects.all(), name='RULES@8' ) misc.print_list(av_slots, name='AVAILABLE@8') self.__verbose_testing = False
def test_sc_get_changes(self): """JRPC test: services.scheduling.sc.getChanges Validates the JRPC method <sc_get_changes>. """ if self.__verbose_testing: print('##### test_gs_get_operational_slots') self.maxDiff = None operational_models.OperationalSlot.objects.reset_ids_counter() # ### channels required for the tests self.assertTrue( jrpc_sc_chs.sc_channel_create( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id, configuration=self.__sc_1_ch_1_cfg ), 'Channel should have been created!' ) self.assertTrue( jrpc_gs_chs.gs_channel_create( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id, configuration=self.__gs_1_ch_1_cfg ), 'Channel should have been created!' ) # 3) we add some slots and they should be retrieved as 'changed' only # once. date_i = misc.get_today_utc() + datetime.timedelta(days=1) date_f = misc.get_today_utc() + datetime.timedelta(days=366) s_time = misc.get_next_midnight() - datetime.timedelta(hours=23) e_time = s_time + datetime.timedelta(hours=20) jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=date_i, date_f=date_f, starting_time=s_time, ending_time=e_time ) ) if self.__verbose_testing: misc.print_list(operational_models.OperationalSlot.objects.all()) self.assertGreater( len(operational_models.OperationalSlot.objects.all()), 0, 'Wrong slots number!' ) # 5) we add some slots and they should be retrieved as 'changed' only # once. date_i = misc.get_today_utc() + datetime.timedelta(days=1) date_f = misc.get_today_utc() + datetime.timedelta(days=366) s_time = misc.get_next_midnight() - datetime.timedelta(hours=23) e_time = s_time + datetime.timedelta(hours=20) jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=date_i, date_f=date_f, starting_time=s_time, ending_time=e_time ) ) self.assertGreater( len(operational_models.OperationalSlot.objects.all()), 0, 'Wrong slots number!' ) # ### clean up sc/gs self.assertTrue( jrpc_gs_chs.gs_channel_delete( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id ), 'Could not delete GroundStationChannel = ' + str( self.__gs_1_ch_1_id ) ) self.assertEquals( len(operational_models.OperationalSlot.objects.all()), 0, 'Expected operational slots to be available' ) self.assertTrue( jrpc_sc_chs.sc_channel_delete( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id ), 'Could not delete SpacecraftChannel = ' + str(self.__sc_1_ch_1_id) ) self.assertEquals( len(operational_models.OperationalSlot.objects.all()), 0, 'Expected operational slots to be available' )
def test_gs_get_operational_slots(self): """JRPC test: services.scheduling.gs.getOperationalSlots Validates the JRPC method <gs_get_operational_slots> """ if self.__verbose_testing: print('##### test_gs_get_operational_slots') self.maxDiff = None operational_models.OperationalSlot.objects.reset_ids_counter() if self.__verbose_testing: print('######### CHECK #1') misc.print_list(availability_models.AvailabilitySlot.objects.all(), name='availability') misc.print_list( compatibility_models.ChannelCompatibility.objects.all(), name='compatibility') misc.print_list(pass_models.PassSlots.objects.all(), name='passes') misc.print_list(operational_models.OperationalSlot.objects.all(), name='operational') # 1) non-existant GroundStation self.assertRaises(models.ObjectDoesNotExist, jrpc_gs_scheduling.get_operational_slots, 0) # 2) basic test, should not generate slots until the GS is added, # raising an exception to confirm it self.assertTrue( jrpc_gs_ch_if.gs_channel_create( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id, configuration=self.__gs_1_ch_1_cfg), 'Channel should have been created!') self.assertRaises(Exception, jrpc_gs_scheduling.get_operational_slots, self.__gs_1_ch_1_id) # 3) basic test, should generate 2 FREE slots self.assertTrue( jrpc_sc_ch_if.sc_channel_create( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id, configuration=self.__sc_1_ch_1_cfg), 'Channel should have been created!') date_i = misc.get_today_utc() + datetime.timedelta(days=1) date_f = misc.get_today_utc() + datetime.timedelta(days=366) s_time = misc.get_next_midnight() - datetime.timedelta(hours=20) e_time = s_time + datetime.timedelta(hours=12) jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule(date_i=date_i, date_f=date_f, starting_time=s_time, ending_time=e_time)) if self.__verbose_testing: print('######### CHECK #2') misc.print_list(availability_models.AvailabilitySlot.objects.all(), name='availability') misc.print_list( compatibility_models.ChannelCompatibility.objects.all(), name='compatibility') misc.print_list(pass_models.PassSlots.objects.all(), name='passes') misc.print_list(operational_models.OperationalSlot.objects.all(), name='operational') self.assertGreater( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0) # ### clean up sc/gs self.assertTrue( jrpc_gs_ch_if.gs_channel_delete(groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id), 'Could not delete GroundStationChannel = ' + str(self.__gs_1_ch_1_id)) self.assertEquals( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0) self.assertTrue( jrpc_sc_ch_if.sc_channel_delete(spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id)) self.assertEquals( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0)
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 test_1_compatibility_sc_channel_added_deleted(self): """INTR test: compatibility changed generates operational slots 1) +GS_CH 2) +RULE 3) +SC_CH 4) -SC_CH 5) -RULE 6) -GS_CH OperationalSlots should be available only in bewteen steps 3 and 4. """ if self.__verbose_testing: print('##### test_add_slots: no rules') 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.assertTrue( jrpc_gs_ch_if.gs_channel_create( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id, configuration=self.__gs_1_ch_1_cfg), 'Channel should have been created!') r_1_id = jrpc_rules_if.add_rule(self.__gs_1_id, self.__rule_1_cfg) self.assertIsNot(r_1_id, 0, 'Rule should have been added!') self.assertTrue( jrpc_sc_ch_if.sc_channel_create( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id, configuration=self.__sc_1_ch_1_cfg), 'Channel should have been created!') a_slots = availability_models.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs_1) if self.__verbose_testing: misc.print_list(a_slots, 'AvailabilitySlots') misc.print_list(operational_models.OperationalSlot.objects.all(), 'OperationalSlots') self.assertGreaterEqual( len(operational_models.OperationalSlot.objects.all()), 2) self.assertTrue( jrpc_sc_ch_if.sc_channel_delete(spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id)) expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE).values_list('state')) if self.__verbose_testing: print('>>> window = ' + str(simulation.OrbitalSimulator.get_simulation_window())) misc.print_list(rule_models.AvailabilityRule.objects.all()) misc.print_list(availability_models.AvailabilitySlot.objects.all()) misc.print_list(operational_models.OperationalSlot.objects.all()) misc.print_list(actual) misc.print_list(expected) self.assertEqual(actual, expected) self.assertTrue(jrpc_rules_if.remove_rule(self.__gs_1_id, r_1_id), 'Rule should have been removed!') expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE).values_list('state')) self.assertEqual(actual, expected) self.assertTrue( jrpc_gs_ch_if.gs_channel_delete(groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id), 'Could not delete GroundStationChannel = ' + str(self.__gs_1_ch_1_id)) expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE).values_list('state')) self.assertEqual(actual, expected)
def test_1_compatibility_sc_channel_added_deleted(self): """INTR test: compatibility changed generates operational slots 1) +GS_CH 2) +RULE 3) +SC_CH 4) -SC_CH 5) -RULE 6) -GS_CH OperationalSlots should be available only in bewteen steps 3 and 4. """ if self.__verbose_testing: print('##### test_add_slots: no rules') 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.assertTrue( jrpc_gs_ch_if.gs_channel_create( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id, configuration=self.__gs_1_ch_1_cfg ), 'Channel should have been created!' ) r_1_id = jrpc_rules_if.add_rule(self.__gs_1_id, self.__rule_1_cfg) self.assertIsNot(r_1_id, 0, 'Rule should have been added!') self.assertTrue( jrpc_sc_ch_if.sc_channel_create( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id, configuration=self.__sc_1_ch_1_cfg ), 'Channel should have been created!' ) a_slots = availability_models.AvailabilitySlot.objects.get_applicable( groundstation=self.__gs_1 ) if self.__verbose_testing: misc.print_list(a_slots, 'AvailabilitySlots') misc.print_list( operational_models.OperationalSlot.objects.all(), 'OperationalSlots' ) self.assertGreaterEqual( len(operational_models.OperationalSlot.objects.all()), 2 ) self.assertTrue( jrpc_sc_ch_if.sc_channel_delete( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id ) ) expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE ).values_list('state') ) if self.__verbose_testing: print('>>> window = ' + str( simulation.OrbitalSimulator.get_simulation_window() )) misc.print_list(rule_models.AvailabilityRule.objects.all()) misc.print_list(availability_models.AvailabilitySlot.objects.all()) misc.print_list(operational_models.OperationalSlot.objects.all()) misc.print_list(actual) misc.print_list(expected) self.assertEqual(actual, expected) self.assertTrue( jrpc_rules_if.remove_rule(self.__gs_1_id, r_1_id), 'Rule should have been removed!' ) expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE ).values_list('state') ) self.assertEqual(actual, expected) self.assertTrue( jrpc_gs_ch_if.gs_channel_delete( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id ), 'Could not delete GroundStationChannel = ' + str( self.__gs_1_ch_1_id ) ) expected = [] actual = list( operational_models.OperationalSlot.objects.filter( state=operational_models.STATE_FREE ).values_list('state') ) self.assertEqual(actual, expected)
def test_gs_get_operational_slots(self): """JRPC test: services.scheduling.gs.getOperationalSlots Validates the JRPC method <gs_get_operational_slots> """ if self.__verbose_testing: print('##### test_gs_get_operational_slots') self.maxDiff = None operational_models.OperationalSlot.objects.reset_ids_counter() if self.__verbose_testing: print('######### CHECK #1') misc.print_list( availability_models.AvailabilitySlot.objects.all(), name='availability' ) misc.print_list( compatibility_models.ChannelCompatibility.objects.all(), name='compatibility' ) misc.print_list( pass_models.PassSlots.objects.all(), name='passes' ) misc.print_list( operational_models.OperationalSlot.objects.all(), name='operational' ) # 1) non-existant GroundStation self.assertRaises( models.ObjectDoesNotExist, jrpc_gs_scheduling.get_operational_slots, 0 ) # 2) basic test, should not generate slots until the GS is added, # raising an exception to confirm it self.assertTrue( jrpc_gs_ch_if.gs_channel_create( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id, configuration=self.__gs_1_ch_1_cfg ), 'Channel should have been created!' ) self.assertRaises( Exception, jrpc_gs_scheduling.get_operational_slots, self.__gs_1_ch_1_id ) # 3) basic test, should generate 2 FREE slots self.assertTrue( jrpc_sc_ch_if.sc_channel_create( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id, configuration=self.__sc_1_ch_1_cfg ), 'Channel should have been created!' ) date_i = misc.get_today_utc() + datetime.timedelta(days=1) date_f = misc.get_today_utc() + datetime.timedelta(days=366) s_time = misc.get_next_midnight() - datetime.timedelta(hours=20) e_time = s_time + datetime.timedelta(hours=12) jrpc_rules.add_rule( self.__gs_1_id, db_tools.create_jrpc_daily_rule( date_i=date_i, date_f=date_f, starting_time=s_time, ending_time=e_time ) ) if self.__verbose_testing: print('######### CHECK #2') misc.print_list( availability_models.AvailabilitySlot.objects.all(), name='availability' ) misc.print_list( compatibility_models.ChannelCompatibility.objects.all(), name='compatibility' ) misc.print_list( pass_models.PassSlots.objects.all(), name='passes' ) misc.print_list( operational_models.OperationalSlot.objects.all(), name='operational' ) self.assertGreater( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0 ) # ### clean up sc/gs self.assertTrue( jrpc_gs_ch_if.gs_channel_delete( groundstation_id=self.__gs_1_id, channel_id=self.__gs_1_ch_1_id ), 'Could not delete GroundStationChannel = ' + str( self.__gs_1_ch_1_id ) ) self.assertEquals( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0 ) self.assertTrue( jrpc_sc_ch_if.sc_channel_delete( spacecraft_id=self.__sc_1_id, channel_id=self.__sc_1_ch_1_id ) ) self.assertEquals( len(jrpc_gs_scheduling.get_operational_slots(self.__gs_1_id)), 0 )