def test_rowCount(good_node_states, good_device_states):
    table_model = DeviceStateTableModel()

    for i, good_states in enumerate(good_node_states):
        table_model.setNodeStates(good_states)
        table_model.setDeviceStates(good_device_states[i])
        assert table_model.rowCount() == len(good_device_states[i]) - 1
def test_headerData(good_node_states, good_device_states):
    table_model = DeviceStateTableModel()

    for i, good_states in enumerate(good_node_states):
        table_model.setNodeStates(good_states)
        table_model.setDeviceStates(good_device_states[i])

        #check vertical header
        for row in range(table_model.rowCount()):
            assert str(row) == table_model.headerData(row, QtCore.Qt.Vertical,
                                                      QtCore.Qt.DisplayRole)

        #Check horizontal headers
        headers = [row[0] for row in good_states]
        headers = headers[::-1]

        for i, val in enumerate(headers):
            assert val == table_model.headerData(i, QtCore.Qt.Horizontal,
                                                 QtCore.Qt.DisplayRole)

        assert 'Status' == table_model.headerData(table_model.statusColumn(),
                                                  QtCore.Qt.Horizontal,
                                                  QtCore.Qt.DisplayRole)
        assert 'Icon Layer\nName' == table_model.headerData(
            table_model.iconLayerColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Is Warning' == table_model.headerData(
            table_model.isWarningColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Warning\nTimeout (sec)' == table_model.headerData(
            table_model.warningTimeoutColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Warning Message' == table_model.headerData(
            table_model.warningMessageColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Is Alarm' == table_model.headerData(
            table_model.isAlarmColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Alarm\nTimeout (sec)' == table_model.headerData(
            table_model.alarmTimeoutColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Alarm Message' == table_model.headerData(
            table_model.alarmMessageColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Triggers\nAction' == table_model.headerData(
            table_model.triggersActionColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Action\nTimeout (sec)' == table_model.headerData(
            table_model.actionTimeoutColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)
        assert 'Action' == table_model.headerData(table_model.actionColumn(),
                                                  QtCore.Qt.Horizontal,
                                                  QtCore.Qt.DisplayRole)
        assert 'Log Entrance' == table_model.headerData(
            table_model.logEntranceColumn(), QtCore.Qt.Horizontal,
            QtCore.Qt.DisplayRole)