File indexing completed on 2024-05-12 05:21:41

0001 # Copyright (c) 2019 Alexander Potashev <aspotashev@gmail.com>
0002 #
0003 # This program is free software; you can redistribute it and/or
0004 # modify it under the terms of the GNU General Public License as
0005 # published by the Free Software Foundation; either version 2 of
0006 # the License or (at your option) version 3 or any later version
0007 # accepted by the membership of KDE e.V. (or its successor approved
0008 # by the membership of KDE e.V.), which shall act as a proxy
0009 # defined in Section 14 of version 3 of the license.
0010 #
0011 # This program is distributed in the hope that it will be useful,
0012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 # GNU General Public License for more details.
0015 #
0016 # You should have received a copy of the GNU General Public License
0017 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 
0019 import time
0020 from datetime import datetime
0021 
0022 
0023 def test_refresh_on_change(app_testfile):
0024     todo_name = 'todo name'
0025     todo_uid = 'abc-123'
0026     todo_time = datetime.now().strftime('%Y%m%dT%H%M%SZ')
0027 
0028     # make sure kdirstat can recognize the change in last change date
0029     time.sleep(1)
0030 
0031     f = open(app_testfile.path(), 'a')
0032     f.write(f"""BEGIN:VCALENDAR
0033 PRODID:-//K Desktop Environment//NONSGML KTimeTracker Test Scripts//EN
0034 VERSION:2.0
0035 
0036 BEGIN:VTODO
0037 DTSTAMP:{todo_time}
0038 ORGANIZER;CN=Anonymous:MAILTO:nobody@nowhere
0039 CREATED:{todo_time}
0040 UID:{todo_uid}
0041 SEQUENCE:0
0042 LAST-MODIFIED:{todo_time}
0043 SUMMARY:{todo_name}
0044 CLASS:PUBLIC
0045 PRIORITY:5
0046 PERCENT-COMPLETE:0
0047 END:VTODO
0048 
0049 END:VCALENDAR
0050 """)
0051     f.close()
0052 
0053     # wait so FAM and KDirWatcher tell karm and karm refreshes view
0054     time.sleep(2)
0055 
0056     task_id = app_testfile.taskIdsFromName(todo_name)[0]
0057     assert task_id == todo_uid