Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests for QgsHistoryEntry::isValid()
  • Loading branch information
nyalldawson committed Apr 22, 2023
1 parent e84ce19 commit eb33b2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/history/qgshistoryentry.cpp
Expand Up @@ -33,5 +33,5 @@ QgsHistoryEntry::QgsHistoryEntry( const QVariantMap &entry )

bool QgsHistoryEntry::isValid() const
{
return !providerId.isEmpty();
return !providerId.isEmpty() || !entry.isEmpty() || timestamp.isValid();
}
7 changes: 7 additions & 0 deletions tests/src/python/test_qgshistoryproviderregistry.py
Expand Up @@ -41,14 +41,21 @@ def test_entry(self):
"""
Test QgsHistoryEntry
"""
entry = QgsHistoryEntry()
self.assertFalse(entry.isValid())

entry = QgsHistoryEntry('my provider', QDateTime(2021, 1, 2, 3, 4, 5), {'somevar': 5})
self.assertTrue(entry.isValid())

self.assertEqual(entry.providerId, 'my provider')
self.assertEqual(entry.timestamp, QDateTime(2021, 1, 2, 3, 4, 5))
self.assertEqual(entry.entry, {'somevar': 5})

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

entry = QgsHistoryEntry({'somevar': 7})
self.assertTrue(entry.isValid())

self.assertFalse(entry.providerId)
self.assertEqual(entry.timestamp.date(), QDateTime.currentDateTime().date())
self.assertEqual(entry.entry, {'somevar': 7})
Expand Down

0 comments on commit eb33b2e

Please sign in to comment.