def test_add_once_rule(self):
        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
JRPC test: (O) cfg.gs.channel.addRule, cfg.gs.channel.removeRule
dataset/ETHPy150Open satnet-project/server/services/configuration/tests/jrpc/test_rules.py/JRPCRulesTest.test_add_once_rule