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 0020 def test_bad_date(app_testfile): 0021 app_testfile.addTask('Task1') 0022 task_id = app_testfile.taskIdsFromName('Task1')[0] 0023 retval = app_testfile.bookTime(task_id, 'notadate', 360) 0024 assert retval == 5 0025 0026 0027 def test_bad_duration(app_testfile): 0028 app_testfile.addTask('Task1') 0029 task_id = app_testfile.taskIdsFromName('Task1')[0] 0030 retval = app_testfile.bookTime(task_id, '20050619', -5) 0031 assert retval == 7 0032 0033 0034 def test_bad_time(app_testfile): 0035 app_testfile.addTask('Task1') 0036 task_id = app_testfile.taskIdsFromName('Task1')[0] 0037 retval = app_testfile.bookTime(task_id, '20050619Tabc', 360) 0038 assert retval == 5 0039 0040 0041 def test_bad_uid(app_testfile): 0042 app_testfile.addTask('Task1') 0043 retval = app_testfile.bookTime('bad-uid', '20050619', 360) 0044 assert retval == 4 0045 0046 0047 def test_valid(app_testfile): 0048 app_testfile.addTask('Task1') 0049 task_id = app_testfile.taskIdsFromName('Task1')[0] 0050 0051 duration = 12 0052 assert app_testfile.bookTime(task_id, '2005-06-19', duration) == 0 0053 0054 assert app_testfile.totalMinutesForTaskId(task_id) == duration