Skip to content

Commit eb33b2e

Browse files
committedApr 22, 2023
Tests for QgsHistoryEntry::isValid()
1 parent e84ce19 commit eb33b2e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎src/gui/history/qgshistoryentry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ QgsHistoryEntry::QgsHistoryEntry( const QVariantMap &entry )
3333

3434
bool QgsHistoryEntry::isValid() const
3535
{
36-
return !providerId.isEmpty();
36+
return !providerId.isEmpty() || !entry.isEmpty() || timestamp.isValid();
3737
}

‎tests/src/python/test_qgshistoryproviderregistry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,21 @@ def test_entry(self):
4141
"""
4242
Test QgsHistoryEntry
4343
"""
44+
entry = QgsHistoryEntry()
45+
self.assertFalse(entry.isValid())
46+
4447
entry = QgsHistoryEntry('my provider', QDateTime(2021, 1, 2, 3, 4, 5), {'somevar': 5})
48+
self.assertTrue(entry.isValid())
49+
4550
self.assertEqual(entry.providerId, 'my provider')
4651
self.assertEqual(entry.timestamp, QDateTime(2021, 1, 2, 3, 4, 5))
4752
self.assertEqual(entry.entry, {'somevar': 5})
4853

4954
self.assertEqual(str(entry), '<QgsHistoryEntry: my provider 2021-01-02T03:04:05>')
5055

5156
entry = QgsHistoryEntry({'somevar': 7})
57+
self.assertTrue(entry.isValid())
58+
5259
self.assertFalse(entry.providerId)
5360
self.assertEqual(entry.timestamp.date(), QDateTime.currentDateTime().date())
5461
self.assertEqual(entry.entry, {'somevar': 7})

0 commit comments

Comments
 (0)
Please sign in to comment.