Ejemplo n.º 1
0
    def test_model_load_symbol_id_conflicts(self):
        model = device.Model(mid=17)
        model.load()

        parity_none_symbol = model.points['Pty'].point_type.symbols[0]
        flow_none_symbol = model.points['Flw'].point_type.symbols[0]

        self.assertEqual(parity_none_symbol.description, 'No Parity')
        self.assertEqual(flow_none_symbol.description, 'No flow control')
Ejemplo n.º 2
0
def create_test_device_1():

    d = device.Device()

    # create model 1 with values
    m1 = device.Model(device=d, mid=1)
    m1.load()
    d.models_list.append(m1)
    b = m1.blocks[0]
    b.points['Mn'].value_base = 'SunSpecTest'
    b.points['Md'].value_base = 'TestDevice-1'
    b.points['Opt'].value_base = 'opt_a_b_c'
    b.points['Vr'].value_base = '1.2.3'
    b.points['SN'].value_base = 'sn-123456789'
    b.points['DA'].value_base = 1

    # create model 63001 with values
    m2 = device.Model(device=d, mid=63001, mlen=188)
    m2.load()
    d.models_list.append(m2)

    # fixed block
    b = m2.blocks[0]
    b.points_sf['sunssf_1'].value_base = -10
    b.points_sf['sunssf_2'].value_base = 10
    b.points_sf['sunssf_3'].value_base = 0
    b.points_sf['sunssf_4'].value_base = 1
    b.points_sf['sunssf_5'].value_base = 2
    b.points_sf['sunssf_6'].value_base = 3
    b.points_sf['sunssf_7'].value_base = 4

    b.points['int16_1'].value_base = 1
    b.points['int16_2'].value_base = -1
    b.points['int16_3'].value_base = 2
    b.points['int16_4'].value_base = -2
    b.points['int16_5'].value_base = 3
    b.points['int16_u'].value_base = None
    b.points['uint16_1'].value_base = 4
    b.points['uint16_2'].value_base = 5
    b.points['uint16_3'].value_base = 65524
    b.points['uint16_4'].value_base = 6
    b.points['uint16_5'].value_base = 7
    b.points['uint16_u'].value_base = None
    b.points['acc16'].value_base = 8
    b.points['acc16_u'].value_base = None
    b.points['enum16'].value_base = 9
    b.points['enum16_u'].value_base = None
    b.points['bitfield16'].value_base = 10
    b.points['bitfield16_u'].value_base = None
    b.points['int32_1'].value_base = 11
    b.points['int32_2'].value_base = 12
    b.points['int32_3'].value_base = 13
    b.points['int32_4'].value_base = 14
    b.points['int32_5'].value_base = 15
    b.points['int32_u'].value_base = None
    b.points['uint32_1'].value_base = 16
    b.points['uint32_2'].value_base = 17
    b.points['uint32_3'].value_base = 18
    b.points['uint32_4'].value_base = 19
    b.points['uint32_5'].value_base = 20
    b.points['uint32_u'].value_base = None
    b.points['acc32'].value_base = 21
    b.points['acc32_u'].value_base = None
    b.points['enum32'].value_base = 22
    b.points['enum32_u'].value_base = None
    b.points['bitfield32'].value_base = 23
    b.points['bitfield32_u'].value_base = None
    b.points['ipaddr'].value_base = 0x01020304
    b.points['ipaddr_u'].value_base = None
    b.points['int64'].value_base = 24
    b.points['int64_u'].value_base = None
    b.points['acc64'].value_base = 25
    b.points['acc64_u'].value_base = None
    b.points['ipv6addr'].value_base = None
    b.points['ipv6addr_u'].value_base = None
    b.points['float32'].value_base = 26
    b.points['float32_u'].value_base = None
    b.points['string'].value_base = '12345678'
    b.points['string_u'].value_base = None

    # repeating block 1
    b = m2.blocks[1]
    b.points_sf['sunssf_8'].value_base = -2
    b.points_sf['sunssf_9'].value_base = -3

    b.points['int16_11'].value_base = 30
    b.points['int16_12'].value_base = 31
    b.points['int16_u'].value_base = None
    b.points['uint16_11'].value_base = 32
    b.points['uint16_12'].value_base = 33
    b.points['uint16_13'].value_base = 34
    b.points['uint16_u'].value_base = None
    b.points['int32'].value_base = 35
    b.points['int32_u'].value_base = None
    b.points['uint32'].value_base = 36
    b.points['uint32_u'].value_base = None

    # repeating block 2
    b = m2.blocks[2]
    b.points_sf['sunssf_8'].value_base = -4
    b.points_sf['sunssf_9'].value_base = -5

    b.points['int16_11'].value_base = 40
    b.points['int16_12'].value_base = 41
    b.points['int16_u'].value_base = None
    b.points['uint16_11'].value_base = 42
    b.points['uint16_12'].value_base = 43
    b.points['uint16_13'].value_base = 44
    b.points['uint16_u'].value_base = None
    b.points['int32'].value_base = 45
    b.points['int32_u'].value_base = None
    b.points['uint32'].value_base = 46
    b.points['uint32_u'].value_base = None

    # repeating block 3
    b = m2.blocks[3]
    b.points_sf['sunssf_8'].value_base = 2
    b.points_sf['sunssf_9'].value_base = 3

    b.points['int16_11'].value_base = 50
    b.points['int16_12'].value_base = 51
    b.points['int16_u'].value_base = None
    b.points['uint16_11'].value_base = 52
    b.points['uint16_12'].value_base = 53
    b.points['uint16_13'].value_base = 54
    b.points['uint16_u'].value_base = None
    b.points['int32'].value_base = 55
    b.points['int32_u'].value_base = None
    b.points['uint32'].value_base = 56
    b.points['uint32_u'].value_base = None

    # update scale factor values in points
    for block in m2.blocks:
        for point in block.points_list:
            if point.sf_point is not None:
                point.value_sf = point.sf_point.value_base

    return d
Ejemplo n.º 3
0
    def test_block_past_end_of_model(self):
        model = device.Model(mid=65000)

        with device.fresh_file_pathlist(test_model_directory):
            with self.assertRaises(util.SunSpecError):
                model.load()