def test_settings_model_empty(self): test_model = models.SettingsModel() assert test_model.rowCount() == 0 assert test_model.columnCount() == 2 index = test_model.index(0, 0) assert index.data() is None assert isinstance(test_model.data(index), QtCore.QVariant)
def test_header_data(self, index, expected): model = models.SettingsModel(None) value = model.headerData(index, QtCore.Qt.Horizontal, role=QtCore.Qt.DisplayRole) assert value == expected
def test_settings_model_added(self): test_model = models.SettingsModel() test_model.add_setting("mysetting", "eggs") assert test_model.rowCount() == 1 assert test_model.columnCount() == 2 assert test_model.index(0, 0).data() == "mysetting" assert test_model.index(0, 1).data() == "eggs" index = test_model.index(0, 1) assert isinstance(test_model.data(index), QtCore.QVariant)
def test_flags(self, column, expected): model = models.SettingsModel(None) model.add_setting("spam", "eggs") flags = model.flags(model.index(0, column)) assert flags == expected
def test_set_data(self): model = models.SettingsModel(None) model.add_setting("spam", "eggs") model.setData(model.index(0, 0), data="dumb") assert model._data[0][1] == "dumb"
def test_data(self, role): model = models.SettingsModel(None) model.add_setting("spam", "eggs") model.data(model.index(0, 0), role=role) == "spam"