Esempio n. 1
0
    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
Esempio n. 2
0
    def test_add_daily_rule(self):
        """JRPC test: (D) cfg.gs.channel.addRule, cfg.gs.channel.removeRule
        Should correctly add a DAILY rule to the system.
        """
        if self.__verbose_testing:
            print('>>> TEST (test_gs_channel_add_rule)')

        now = misc.get_now_utc()
        r_1_s_time = now + datetime.timedelta(minutes=30)
        r_1_e_time = now + datetime.timedelta(minutes=45)

        # 1) A daily rule is inserted in the database:
        rule_cfg = db_tools.create_jrpc_daily_rule(
            starting_time=r_1_s_time,
            ending_time=r_1_e_time
        )
        rule_pk = 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_pk,
            jrpc_serial.RULE_PERIODICITY: jrpc_serial.RULE_PERIODICITY_DAILY,
            jrpc_serial.RULE_OP: jrpc_serial.RULE_OP_ADD,
            jrpc_serial.RULE_DATES: {
                jrpc_serial.RULE_DAILY_I_DATE: common_serial
                .serialize_iso8601_date(
                    misc.get_today_utc() + datetime.timedelta(days=1)
                ),
                jrpc_serial.RULE_DAILY_F_DATE: common_serial
                .serialize_iso8601_date(
                    misc.get_today_utc() + datetime.timedelta(days=366)
                ),
                jrpc_serial.RULE_S_TIME: common_serial
                .serialize_iso8601_time(
                    r_1_s_time
                ),
                jrpc_serial.RULE_E_TIME: common_serial
                .serialize_iso8601_time(
                    r_1_e_time
                )
            }
        }

        if self.__verbose_testing:
            print('>>> rules from JRPC[' + str(len(rules_g1c1)) + ']:')
            for r in rules_g1c1:
                misc.print_dictionary(r)
            print('>>> expected_r:')
            misc.print_dictionary(expected_r)

        self.assertEqual(rules_g1c1[0], expected_r)
Esempio n. 3
0
    def test_sc_channel_get_configuration(self):
        """JRPC test: configuration.sc.channel.getConfiguration
        """
        try:
            jrpc_sc_channels_if.sc_channel_get_configuration(
                'FAKE-SC', 'FAKE-SC-CHANNEL'
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_get_configuration(
                self.__sc_1_id, 'FAKE-SC-CHANNEL'
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__sc_1_ch_2_id,
            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.assertEqual(
            jrpc_sc_channels_if.sc_channel_create(
                spacecraft_id=self.__sc_1_id,
                channel_id=self.__sc_1_ch_2_id,
                configuration=expected_c
            ), True, 'Channel should have been created!'
        )

        actual_c = jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_2_id
        )

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(
            actual_c, expected_c,
            'Configuration dictionaries do not match!'
        )
        db_tools.remove_sc_channel(self.__sc_1_ch_2_id)
Esempio n. 4
0
    def test_gs_channel_get_configuration(self):
        """JRPC test: configuration.gs.channel.getConfiguration
        """
        try:
            jrpc_gs_channels_if.gs_channel_get_configuration(
                'FAKE-GS', 'FAKE-GS-CHANNEL'
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_get_configuration(
                self.__gs_1_id, 'FAKE-GS-CHANNEL'
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__gs_1_ch_2_id,
            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]
        }
        self.assertTrue(
            jrpc_gs_channels_if.gs_channel_create(
                groundstation_id=self.__gs_1_id,
                channel_id=self.__gs_1_ch_2_id,
                configuration=expected_c
            ),
            'Channel should have been created!'
        )

        actual_c = jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_2_id
        )

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
        db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_2_id)
Esempio n. 5
0
    def test_gs_get_configuration(self):
        """JRPC test: configuration.gs.getConfiguration
        This test validates the returned configuration by the proper JRPC
        method.
        """
        if self.__verbose_testing:
            print('>>> TEST (test_gs_get_configuration):')

        cfg = segment_serializaers.deserialize_gs_configuration(
            jrpc_gs.get_configuration(self.__gs_1_id)
        )

        if self.__verbose_testing:
            misc.print_dictionary(cfg)
            misc.print_dictionary(self.__gs_1_configuration)

        self.assertEqual(cfg, self.__gs_1_configuration)
Esempio n. 6
0
    def test_add_daily_rule(self):
        """JRPC test: (D) cfg.gs.channel.addRule, cfg.gs.channel.removeRule
        Should correctly add a DAILY rule to the system.
        """
        if self.__verbose_testing:
            print('>>> TEST (test_gs_channel_add_rule)')

        now = misc.get_now_utc()
        r_1_s_time = now + datetime.timedelta(minutes=30)
        r_1_e_time = now + datetime.timedelta(minutes=45)

        # 1) A daily rule is inserted in the database:
        rule_cfg = db_tools.create_jrpc_daily_rule(starting_time=r_1_s_time,
                                                   ending_time=r_1_e_time)
        rule_pk = 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_pk,
            jrpc_serial.RULE_PERIODICITY: jrpc_serial.RULE_PERIODICITY_DAILY,
            jrpc_serial.RULE_OP: jrpc_serial.RULE_OP_ADD,
            jrpc_serial.RULE_DATES: {
                jrpc_serial.RULE_DAILY_I_DATE:
                common_serial.serialize_iso8601_date(misc.get_today_utc() +
                                                     datetime.timedelta(
                                                         days=1)),
                jrpc_serial.RULE_DAILY_F_DATE:
                common_serial.serialize_iso8601_date(misc.get_today_utc() +
                                                     datetime.timedelta(
                                                         days=366)),
                jrpc_serial.RULE_S_TIME:
                common_serial.serialize_iso8601_time(r_1_s_time),
                jrpc_serial.RULE_E_TIME:
                common_serial.serialize_iso8601_time(r_1_e_time)
            }
        }

        if self.__verbose_testing:
            print('>>> rules from JRPC[' + str(len(rules_g1c1)) + ']:')
            for r in rules_g1c1:
                misc.print_dictionary(r)
            print('>>> expected_r:')
            misc.print_dictionary(expected_r)

        self.assertEqual(rules_g1c1[0], expected_r)
Esempio n. 7
0
    def test_sc_channel_get_configuration(self):
        """JRPC test: configuration.sc.channel.getConfiguration
        """
        try:
            jrpc_sc_channels_if.sc_channel_get_configuration(
                'FAKE-SC', 'FAKE-SC-CHANNEL')
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_get_configuration(
                self.__sc_1_id, 'FAKE-SC-CHANNEL')
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__sc_1_ch_2_id,
            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.assertEqual(
            jrpc_sc_channels_if.sc_channel_create(
                spacecraft_id=self.__sc_1_id,
                channel_id=self.__sc_1_ch_2_id,
                configuration=expected_c), True,
            'Channel should have been created!')

        actual_c = jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_2_id)

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c,
                         'Configuration dictionaries do not match!')
        db_tools.remove_sc_channel(self.__sc_1_ch_2_id)
Esempio n. 8
0
    def test_gs_channel_get_configuration(self):
        """JRPC test: configuration.gs.channel.getConfiguration
        """
        try:
            jrpc_gs_channels_if.gs_channel_get_configuration(
                'FAKE-GS', 'FAKE-GS-CHANNEL')
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_get_configuration(
                self.__gs_1_id, 'FAKE-GS-CHANNEL')
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__gs_1_ch_2_id,
            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]
        }
        self.assertTrue(
            jrpc_gs_channels_if.gs_channel_create(
                groundstation_id=self.__gs_1_id,
                channel_id=self.__gs_1_ch_2_id,
                configuration=expected_c), 'Channel should have been created!')

        actual_c = jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_2_id)

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
        db_tools.remove_gs_channel(self.__gs_1_id, self.__gs_1_ch_2_id)
Esempio n. 9
0
    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
Esempio n. 10
0
    def test_sc_channel_set_configuration(self):
        """JRPC test: configuration.sc.channel.setConfiguration
        """
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                'FAKE-SC', 'FAKE-SC-CHANNEL', None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, 'FAKE-SC-CHANNEL', None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {})
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_1_id)

        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {
                    channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
                    channel_serializers.FREQUENCY_K: 438000000,
                    channel_serializers.MODULATION_K: 'XM',
                    channel_serializers.POLARIZATION_K: 'RHCP',
                    channel_serializers.BITRATE_K: 600,
                    channel_serializers.BANDWIDTH_K: 25
                })
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {
                    channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
                    channel_serializers.FREQUENCY_K: 438000000,
                    channel_serializers.MODULATION_K: 'FM',
                    channel_serializers.POLARIZATION_K: 'XHHMP',
                    channel_serializers.BITRATE_K: 600,
                    channel_serializers.BANDWIDTH_K: 25
                })
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
            channel_serializers.FREQUENCY_K: 438000000,
            channel_serializers.MODULATION_K: 'FM',
            channel_serializers.POLARIZATION_K: 'RHCP',
            channel_serializers.BITRATE_K: 600,
            channel_serializers.BANDWIDTH_K: 25
        }

        self.assertEqual(
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, expected_c), True,
            'Configuration should have been set correctly!')

        actual_c = jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_1_id)

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
Esempio n. 11
0
    def test_gs_channel_set_configuration(self):
        """JRPC test: configuration.gs.channel.setConfiguration
        """
        self.__verbose_testing = False
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                'FAKE-GS', 'FAKE-GS-CHANNEL', None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, 'FAKE-GS-CHANNEL', None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, None)
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {})
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_1_id)

        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {
                    channel_serializers.BAND_K:
                    'UHF / U / 435000000.000000 / 438000000.000000',
                    channel_serializers.AUTOMATED_K: False,
                    channel_serializers.MODULATIONS_K: ['HM'],
                    channel_serializers.POLARIZATIONS_K: ['LHCP'],
                    channel_serializers.BITRATES_K: [600],
                    channel_serializers.BANDWIDTHS_K: [25]
                })
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {
                    channel_serializers.BAND_K:
                    'UHF / U / 435000000.000000 / 438000000.000000',
                    channel_serializers.AUTOMATED_K: False,
                    channel_serializers.MODULATIONS_K: ['FM'],
                    channel_serializers.POLARIZATIONS_K: ['XHHMP'],
                    channel_serializers.BITRATES_K: [600],
                    channel_serializers.BANDWIDTHS_K: [25]
                })
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__gs_1_ch_1_id,
            channel_serializers.BAND_K:
            'UHF / U / 435000000.000000 / 438000000.000000',
            channel_serializers.AUTOMATED_K: False,
            channel_serializers.MODULATIONS_K: [str('AFSK'),
                                                str('FM')],
            channel_serializers.POLARIZATIONS_K: [str('LHCP'),
                                                  str('RHCP')],
            channel_serializers.BITRATES_K: [300, 600],
            channel_serializers.BANDWIDTHS_K: [25]
        }

        self.assertEqual(
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, expected_c), True,
            'Configuration should have been set correctly!')

        actual_c = jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_1_id)

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
Esempio n. 12
0
    def test_sc_channel_set_configuration(self):
        """JRPC test: configuration.sc.channel.setConfiguration
        """
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                'FAKE-SC', 'FAKE-SC-CHANNEL', None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, 'FAKE-SC-CHANNEL', None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {}
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_1_id
        )

        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {
                    channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
                    channel_serializers.FREQUENCY_K: 438000000,
                    channel_serializers.MODULATION_K: 'XM',
                    channel_serializers.POLARIZATION_K: 'RHCP',
                    channel_serializers.BITRATE_K: 600,
                    channel_serializers.BANDWIDTH_K: 25
                }
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        try:
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, {
                    channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
                    channel_serializers.FREQUENCY_K: 438000000,
                    channel_serializers.MODULATION_K: 'FM',
                    channel_serializers.POLARIZATION_K: 'XHHMP',
                    channel_serializers.BITRATE_K: 600,
                    channel_serializers.BANDWIDTH_K: 25
                }
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__sc_1_ch_1_id,
            channel_serializers.FREQUENCY_K: 438000000,
            channel_serializers.MODULATION_K: 'FM',
            channel_serializers.POLARIZATION_K: 'RHCP',
            channel_serializers.BITRATE_K: 600,
            channel_serializers.BANDWIDTH_K: 25
        }

        self.assertEqual(
            jrpc_sc_channels_if.sc_channel_set_configuration(
                self.__sc_1_id, self.__sc_1_ch_1_id, expected_c
            ),
            True,
            'Configuration should have been set correctly!'
        )

        actual_c = jrpc_sc_channels_if.sc_channel_get_configuration(
            self.__sc_1_id, self.__sc_1_ch_1_id
        )

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
Esempio n. 13
0
    def test_gs_channel_set_configuration(self):
        """JRPC test: configuration.gs.channel.setConfiguration
        """
        self.__verbose_testing = False
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                'FAKE-GS', 'FAKE-GS-CHANNEL', None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, 'FAKE-GS-CHANNEL', None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, None
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass
        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {}
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_1_id
        )

        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {
                    channel_serializers.BAND_K:
                        'UHF / U / 435000000.000000 / 438000000.000000',
                    channel_serializers.AUTOMATED_K: False,
                    channel_serializers.MODULATIONS_K: ['HM'],
                    channel_serializers.POLARIZATIONS_K: ['LHCP'],
                    channel_serializers.BITRATES_K: [600],
                    channel_serializers.BANDWIDTHS_K: [25]
                }
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        try:
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, {
                    channel_serializers.BAND_K:
                    'UHF / U / 435000000.000000 / 438000000.000000',
                    channel_serializers.AUTOMATED_K: False,
                    channel_serializers.MODULATIONS_K: ['FM'],
                    channel_serializers.POLARIZATIONS_K: ['XHHMP'],
                    channel_serializers.BITRATES_K: [600],
                    channel_serializers.BANDWIDTHS_K: [25]
                }
            )
            self.fail('An exception should have been thrown!')
        except Exception:
            pass

        expected_c = {
            channel_serializers.CH_ID_K: self.__gs_1_ch_1_id,
            channel_serializers.BAND_K:
                'UHF / U / 435000000.000000 / 438000000.000000',
            channel_serializers.AUTOMATED_K: False,
            channel_serializers.MODULATIONS_K: [str('AFSK'), str('FM')],
            channel_serializers.POLARIZATIONS_K: [str('LHCP'), str('RHCP')],
            channel_serializers.BITRATES_K: [300, 600],
            channel_serializers.BANDWIDTHS_K: [25]
        }

        self.assertEqual(
            jrpc_gs_channels_if.gs_channel_set_configuration(
                self.__gs_1_id, self.__gs_1_ch_1_id, expected_c
            ),
            True,
            'Configuration should have been set correctly!'
        )

        actual_c = jrpc_gs_channels_if.gs_channel_get_configuration(
            self.__gs_1_id, self.__gs_1_ch_1_id
        )

        if self.__verbose_testing:
            misc.print_dictionary(actual_c)
            misc.print_dictionary(expected_c)

        self.assertEqual(actual_c, expected_c)
Esempio n. 14
0
    def test_get_configuration(self):
        """JRPC test: services.leop.getConfiguration
        Validation of the JRPC method that permits obtaining the
        configuration for a given LEOP cluster.
        """
        self.assertRaises(
            launch_models.Launch.DoesNotExist, launch_jrpc.get_configuration, ''
        )

        # 1) No ufos
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID: str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID: str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE: self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }
        self.assertEqual(a_cfg, e_cfg)

        # 2) 1 ufo
        launch_jrpc.add_unknown(self.__leop_id, 1)
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID: str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID: str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE: self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [
                {launch_serial.JRPC_K_OBJECT_ID: '1'}
            ],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }
        self.assertEqual(a_cfg, e_cfg)

        # 3) 1 ufo, 1 identified
        launch_jrpc.add_unknown(self.__leop_id, 2)
        launch_jrpc.identify(
            self.__leop_id, self.__ufo_id, self.__ufo_callsign,
            self.__ufo_tle_l1, self.__ufo_tle_l2
        )

        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID: str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID: str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE: self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [
                {launch_serial.JRPC_K_OBJECT_ID: '2'}
            ],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: [{
                launch_serial.JRPC_K_OBJECT_ID: '1',
                launch_serial.JRPC_K_SC_ID: str(self.__ufo_sc_id),
                launch_serial.JRPC_K_CALLSIGN: str(self.__ufo_callsign),
                launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
                launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            }]
        }
        self.assertEqual(a_cfg, e_cfg)

        # 4) 2 ufos
        launch_jrpc.forget(self.__leop_id, self.__ufo_id)
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID: str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID: str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE: self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [
                {launch_serial.JRPC_K_OBJECT_ID: '2'},
                {launch_serial.JRPC_K_OBJECT_ID: '1'}
            ],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }

        if self.__verbose_testing:
            misc.print_dictionary(a_cfg)
            misc.print_dictionary(e_cfg)

        self.assertEqual(a_cfg, e_cfg)
Esempio n. 15
0
    def test_get_configuration(self):
        """JRPC test: services.leop.getConfiguration
        Validation of the JRPC method that permits obtaining the
        configuration for a given LEOP cluster.
        """
        self.assertRaises(launch_models.Launch.DoesNotExist,
                          launch_jrpc.get_configuration, '')

        # 1) No ufos
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID: str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID: str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE: self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1: self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2: self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }
        self.assertEqual(a_cfg, e_cfg)

        # 2) 1 ufo
        launch_jrpc.add_unknown(self.__leop_id, 1)
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID:
            str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID:
            str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE:
            self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1:
            self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2:
            self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [{
                launch_serial.JRPC_K_OBJECT_ID:
                '1'
            }],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }
        self.assertEqual(a_cfg, e_cfg)

        # 3) 1 ufo, 1 identified
        launch_jrpc.add_unknown(self.__leop_id, 2)
        launch_jrpc.identify(self.__leop_id, self.__ufo_id,
                             self.__ufo_callsign, self.__ufo_tle_l1,
                             self.__ufo_tle_l2)

        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID:
            str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID:
            str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE:
            self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1:
            self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2:
            self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [{
                launch_serial.JRPC_K_OBJECT_ID:
                '2'
            }],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: [{
                launch_serial.JRPC_K_OBJECT_ID:
                '1',
                launch_serial.JRPC_K_SC_ID:
                str(self.__ufo_sc_id),
                launch_serial.JRPC_K_CALLSIGN:
                str(self.__ufo_callsign),
                launch_serial.JRPC_K_TLE_L1:
                self.__leop_tle_l1,
                launch_serial.JRPC_K_TLE_L2:
                self.__leop_tle_l2,
            }]
        }
        self.assertEqual(a_cfg, e_cfg)

        # 4) 2 ufos
        launch_jrpc.forget(self.__leop_id, self.__ufo_id)
        a_cfg = launch_jrpc.get_configuration(self.__leop_id)
        e_cfg = {
            launch_serial.JRPC_K_LEOP_ID:
            str(self.__leop_id),
            launch_serial.JRPC_K_SC_ID:
            str(self.__leop_sc_id),
            launch_serial.JRPC_K_DATE:
            self.__leop_serial_date,
            launch_serial.JRPC_K_TLE_L1:
            self.__leop_tle_l1,
            launch_serial.JRPC_K_TLE_L2:
            self.__leop_tle_l2,
            launch_serial.JRPC_K_UNKNOWN_OBJECTS: [{
                launch_serial.JRPC_K_OBJECT_ID:
                '2'
            }, {
                launch_serial.JRPC_K_OBJECT_ID:
                '1'
            }],
            launch_serial.JRPC_K_IDENTIFIED_OBJECTS: []
        }

        if self.__verbose_testing:
            misc.print_dictionary(a_cfg)
            misc.print_dictionary(e_cfg)

        self.assertEqual(a_cfg, e_cfg)