Esempio n. 1
0
    def test_parameters_select(self):
        param = Parameter.objects.create(name='param_select', typeparam=4)
        param.args = "{'Enum':4}"
        param.value = '2'
        param.save()

        Params.fill(self.xfer, ['param_select'], 1, 1, True)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('LABELFORM', "param_select", 'param_select.2')

        Params.fill(self.xfer, ['param_select'], 1, 1, False)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('SELECT', "param_select", '2')
        self.assert_select_equal(
            "param_select", {
                0: 'param_select.0',
                1: 'param_select.1',
                2: 'param_select.2',
                3: 'param_select.3'
            })

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'param_select',
            'param_select': '1'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')
        self.assertEqual(Params.getvalue('param_select'), 1)
Esempio n. 2
0
    def test_parameters_float(self):
        param = Parameter.objects.create(name='param_float', typeparam=2)
        param.args = "{'Min':20, 'Max':30, 'Prec':2}"
        param.value = '22.25'
        param.save()

        Params.fill(self.xfer, ['param_float'], 1, 1, True)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('LABELFORM', "param_float", '22.25')

        Params.fill(self.xfer, ['param_float'], 1, 1, False)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('FLOAT', "param_float", '22.25')
        self.assert_attrib_equal("param_float", 'min', '20.0')
        self.assert_attrib_equal("param_float", 'max', '30.0')
        self.assert_attrib_equal("param_float", 'prec', '2')

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'param_float',
            'param_float': '26.87'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')
        self.assertEqual(Params.getvalue('param_float'), 26.87)
Esempio n. 3
0
    def test_parameters_int(self):
        param = Parameter.objects.create(name='param_int', typeparam=1)
        param.args = "{'Min':5, 'Max':25}"
        param.value = '5'
        param.save()

        Params.fill(self.xfer, ['param_int'], 1, 1, True)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('LABELFORM', "param_int", '5')

        Params.fill(self.xfer, ['param_int'], 1, 1, False)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('FLOAT', "param_int", '5')
        self.assert_attrib_equal("param_int", 'min', '5.0')
        self.assert_attrib_equal("param_int", 'max', '25.0')
        self.assert_attrib_equal("param_int", 'prec', '0')

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'param_int',
            'param_int': '13'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')
        self.assertEqual(Params.getvalue('param_int'), 13)
Esempio n. 4
0
    def test_config_save(self):
        param = Parameter.objects.get(name='CORE-connectmode')
        self.assertEqual("0", param.value)

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'CORE-connectmode',
            'CORE-connectmode': '1'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')

        param = Parameter.objects.get(name='CORE-connectmode')
        self.assertEqual("1", param.value)
Esempio n. 5
0
    def test_parameters_bool(self):
        param = Parameter.objects.create(name='param_bool', typeparam=3)
        param.args = "{}"
        param.value = 'False'
        param.save()

        Params.fill(self.xfer, ['param_bool'], 1, 1, True)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('LABELFORM', "param_bool", 'Non')

        Params.fill(self.xfer, ['param_bool'], 1, 1, False)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('CHECK', "param_bool", '0')

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'param_bool',
            'param_bool': '1'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')
        self.assertEqual(Params.getvalue('param_bool'), True)
Esempio n. 6
0
    def test_parameters_memo(self):
        param = Parameter.objects.create(name='param_memo', typeparam=0)
        param.args = "{'Multi':True}"
        param.value = 'other value'
        param.save()

        Params.fill(self.xfer, ['param_memo'], 1, 1, True)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('LABELFORM', "param_memo", 'other value')

        Params.fill(self.xfer, ['param_memo'], 1, 1, False)
        self.callparam()
        self.assert_count_equal('', 1)
        self.assert_json_equal('MEMO', "param_memo", 'other value')

        self.factory.xfer = ParamSave()
        self.calljson('/CORE/paramSave', {
            'params': 'param_memo',
            'param_memo': 'new special value'
        }, False)
        self.assert_observer('core.acknowledge', 'CORE', 'paramSave')
        self.assertEqual(Params.getvalue('param_memo'), 'new special value')