Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusHackspacher authored Oct 14, 2024
1 parent 3f0ea6f commit cdb9ef7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_sqlAlchemyTableModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Archerank2
Copyright (C) <2019,2023> Markus Hackspacher
Copyright (C) <2019-2024> Markus Hackspacher
This file is part of Archerank2.
Expand All @@ -23,7 +23,10 @@

from unittest import TestCase

from PyQt5.Qt import QMetaType, QModelIndex, Qt
try:
from PyQt6.Qt import QMetaType, QModelIndex, Qt
except ImportError:
from PyQt5.Qt import QMetaType, QModelIndex, Qt
from sqlalchemy import create_engine, orm

from modules import model
Expand Down Expand Up @@ -63,7 +66,7 @@ def test_headerData(self):
self.assertEqual(header.canConvert(QMetaType.QString), True)
self.assertEqual(header.value(), 'Lastname')

header = self.model_user.headerData(0, Qt.Vertical, Qt.DisplayRole)
header = self.model_user.headerData(0, Qt.Vertical, Qt.ItemDataRole.DisplayRole)
self.assertEqual(header.value(), None)

def test_setFilter(self):
Expand All @@ -85,7 +88,7 @@ def test_dropMimeData(self):
self.model_user.dropMimeData('name', Qt.MoveAction, 0, 2, index), False)
self.assertEqual(
self.model_user.dropMimeData('a', Qt.DropAction, 0, 2, index), None)
self.assertEqual(self.model_user.data(index, Qt.DisplayRole), 'John')
self.assertEqual(self.model_user.data(index, Qt.ItemDataRole.DisplayRole), 'John')

def test_rowCount(self):
self.assertEqual(self.model_user.rowCount(), 0)
Expand All @@ -106,11 +109,11 @@ def test_data(self):
self.model_user.refresh()
index = self.model_user.createIndex(0, 1)
self.assertEqual(index.isValid(), True)
self.assertEqual(self.model_user.data(index, Qt.DisplayRole), 'Dow')
self.assertEqual(self.model_user.data(index, Qt.ItemDataRole.DisplayRole), 'Dow')
index = self.model_user.createIndex(0, 2)
self.assertEqual(self.model_user.data(index, Qt.DisplayRole), 'John')
self.assertEqual(self.model_user.data(index, Qt.ItemDataRole.DisplayRole), 'John')
self.assertEqual(self.model_user.setData(index, 'Jonny'), True)
self.assertEqual(self.model_user.data(index, Qt.DisplayRole), 'Jonny')
self.assertEqual(self.model_user.data(index, Qt.ItemDataRole.DisplayRole), 'Jonny')

def test_refresh(self):
self.session.add(model.User(name='John', lastname='Dow'))
Expand Down

0 comments on commit cdb9ef7

Please sign in to comment.