1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
|
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase
class TestDescriptionFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,description")
cls.t.config("verbose", "nothing")
cls.t("add zero")
cls.t("add one long description to exceed a certain string size")
cls.t("2 annotate annotation")
def setUp(self):
"""Executed before each test in the class"""
def test_description_combined(self):
"""Verify formatting of 'description.combined' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,description.combined")
self.assertIn("one long description to exceed a certain string size", out)
self.assertRegexpMatches(out, r"\d{4}-\d{2}-\d{2} annotation")
self.assertNotIn("[1]", out)
def test_description_desc(self):
"""Verify formatting of 'description.desc' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,description.desc")
self.assertIn("one long description to exceed a certain string size", out)
self.assertNotIn("[1]", out)
def test_description_oneline(self):
"""Verify formatting of 'description.oneline' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,description.oneline")
self.assertRegexpMatches(out, r"one long description to exceed a certain string size \d{4}-\d{2}-\d{2}")
self.assertIn("annotation", out)
self.assertNotIn("[1]", out)
def test_description_truncated(self):
"""Verify formatting of 'description.truncated' column"""
code, out, err = self.t("xxx rc.detection:off rc.defaultwidth:40 rc.report.xxx.columns:id,description.truncated")
self.assertIn("exceed a c...", out)
self.assertNotIn("annotation", out)
self.assertNotIn("[1]", out)
def test_description_count(self):
"""Verify formatting of 'description.count' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,description.count")
self.assertIn("size [1]", out)
self.assertNotIn("annotation", out)
def test_description_truncated_count(self):
"""Verify formatting of 'description.truncated_count' column"""
code, out, err = self.t("xxx rc.detection:off rc.defaultwidth:40 rc.report.xxx.columns:id,description.truncated_count")
self.assertIn("exceed... [1]", out)
self.assertNotIn("annotation", out)
def test_description_format_unrecognized(self):
"""Verify descriptionuuid.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,description.donkey")
self.assertEqual(err, "Unrecognized column format 'description.donkey'\n")
class TestUUIDFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,uuid")
cls.t.config("verbose", "nothing")
cls.t("add zero")
code, out, err = cls.t("_get 1.uuid")
cls.uuid = out.strip()
def setUp(self):
"""Executed before each test in the class"""
def test_uuid_long(self):
"""Verify formatting of 'uuid.long' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,uuid.long")
self.assertIn(self.uuid, out)
def test_uuid_short(self):
"""Verify formatting of 'uuid.short' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,uuid.short")
self.assertIn(self.uuid[:7], out)
def test_uuid_format_unrecognized(self):
"""Verify uuid.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,uuid.donkey")
self.assertEqual(err, "Unrecognized column format 'uuid.donkey'\n")
class TestUrgencyFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,urgency")
cls.t.config("verbose", "nothing")
cls.t("add one project:A due:yesterday +tag")
def setUp(self):
"""Executed before each test in the class"""
def test_urgency_real(self):
"""Verify formatting of 'urgency.real' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,urgency.real")
self.assertIn("11.", out)
def test_urgency_integer(self):
"""Verify formatting of 'urgency.integer' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,urgency.integer")
self.assertIn("11", out)
self.assertNotIn("11.", out)
def test_urgency_format_unrecognized(self):
"""Verify urgency.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,urgency.donkey")
self.assertEqual(err, "Unrecognized column format 'urgency.donkey'\n")
class TestIDFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id")
cls.t.config("verbose", "nothing")
cls.t("add zero")
def setUp(self):
"""Executed before each test in the class"""
def test_id_number(self):
"""Verify formatting of 'id.number' column"""
code, out, err = self.t("xxx ")
code, out, err = self.t("xxx rc.report.xxx.columns:id.number")
self.assertEqual(" 1\n", out)
def test_id_format_unrecognized(self):
"""Verify id.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id.donkey")
self.assertEqual(err, "Unrecognized column format 'id.donkey'\n")
class TestStatusFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,status")
cls.t.config("verbose", "nothing")
cls.t("add zero")
cls.t("add one")
cls.t("2 delete", input="y\n")
cls.t("log two")
cls.t("add three due:eom recur:weekly")
cls.t("add four wait:eom")
cls.t("list")
def setUp(self):
"""Executed before each test in the class"""
def test_status_short(self):
"""Verify formatting of 'status.short' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,status.short")
self.assertIn(" 1 P", out)
self.assertIn(" 2 R", out)
self.assertIn(" 3 W", out)
self.assertIn(" 4 P", out)
self.assertIn(" - D", out)
self.assertIn(" - C", out)
def test_status_long(self):
"""Verify formatting of 'status.long' column"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,status.long")
self.assertIn(" 1 Pending", out)
self.assertIn(" 2 Recurring", out)
self.assertIn(" 3 Waiting", out)
self.assertIn(" 4 Pending", out)
self.assertIn(" - Deleted", out)
self.assertIn(" - Completed", out)
def test_status_format_unrecognized(self):
"""Verify status.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,status.donkey")
self.assertEqual(err, "Unrecognized column format 'status.donkey'\n")
class TestRecurringAttributeFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id")
cls.t.config("verbose", "nothing")
cls.t("add one due:eoy recur:monthly")
cls.t("list")
def setUp(self):
"""Executed before each test in the class"""
def test_recurrence_formats_short(self):
"""Verify formatting of assorted short recurrence columns"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,status,due,recur.indicator,mask,imask,parent.short")
self.assertRegexpMatches(out, "1\sRecurring\s+\d{4}-\d{2}-\d{2}\s+R\s+-")
self.assertRegexpMatches(out, "2\sPending\s+\d{4}-\d{2}-\d{2}\s+R\s+0\s+[0-9a-fA-F]{8}")
def test_recurrence_formats_long(self):
"""Verify formatting of assorted long recurrence columns"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,status,due,recur.duration,mask,imask,parent.long")
self.assertRegexpMatches(out, "1\sRecurring\s+\d{4}-\d{2}-\d{2}\s+P30D\s+-")
self.assertRegexpMatches(out, "2\sPending\s+\d{4}-\d{2}-\d{2}\s+P30D\s+0\s+[0-9a-fA-F-]{36}")
def test_recurrence_format_unrecognized(self):
"""Verify *.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,status,due,recur.donkey,mask,imask,parent.long")
self.assertEqual(err, "Unrecognized column format 'recur.donkey'\n")
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,status,due,recur.duration,mask,imask,parent.donkey")
self.assertEqual(err, "Unrecognized column format 'parent.donkey'\n")
class TestProjectFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,project,description")
cls.t.config("verbose", "nothing")
cls.t("add one project:TOP")
cls.t("add two project:TOP.MIDDLE")
cls.t("add three project:TOP.MIDDLE.BOTTOM")
def setUp(self):
"""Executed before each test in the class"""
def test_project_format_full(self):
"""Verify project.full formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,project.full,description")
self.assertRegexpMatches(out, r'1\s+TOP\s+one')
self.assertRegexpMatches(out, r'2\s+TOP.MIDDLE\s+two')
self.assertRegexpMatches(out, r'3\s+TOP.MIDDLE.BOTTOM\s+three')
def test_project_format_parent(self):
"""Verify project.parent formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,project.parent,description")
self.assertRegexpMatches(out, r'1\s+TOP\s+one')
self.assertRegexpMatches(out, r'2\s+TOP\s+two')
self.assertRegexpMatches(out, r'3\s+TOP\s+three')
def test_project_format_indented(self):
"""Verify project.indented formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,project.indented,description")
self.assertRegexpMatches(out, r'1\s+TOP\s+one')
self.assertRegexpMatches(out, r'2\s+MIDDLE\s+two')
self.assertRegexpMatches(out, r'3\s+BOTTOM\s+three')
def test_project_format_unrecognized(self):
"""Verify project.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,project.donkey,description")
self.assertEqual(err, "Unrecognized column format 'project.donkey'\n")
class TestTagsFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,tags,description")
cls.t.config("verbose", "nothing")
cls.t("add one +tag1 +tag2")
def test_tags_format_list(self):
"""Verify tags.list formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,tags.list")
self.assertRegexpMatches(out, r'1\s+tag1\stag2$')
def test_tags_format_indicator(self):
"""Verify tags.indicator formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,tags.indicator")
self.assertRegexpMatches(out, r'1\s+\+$')
def test_tags_format_count(self):
"""Verify tags.count formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,tags.count")
self.assertRegexpMatches(out, r'1\s+\[2\]$')
def test_tags_format_unrecognized(self):
"""Verify tags.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,tags.donkey,description")
self.assertEqual(err, "Unrecognized column format 'tags.donkey'\n")
class TestDateFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,due")
cls.t.config("verbose", "nothing")
cls.t("add one due:yesterday")
cls.t("add two due:tomorrow")
def test_date_format_formatted(self):
"""Verify due.formatted formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.formatted")
self.assertRegexpMatches(out, r'1\s+\d{4}-\d{2}-\d{2}')
self.assertRegexpMatches(out, r'2\s+\d{4}-\d{2}-\d{2}')
def test_date_format_julian(self):
"""Verify due.julian formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.julian")
self.assertRegexpMatches(out, r'1\s+\d+\.\d+')
self.assertRegexpMatches(out, r'2\s+\d+\.\d+')
def test_date_format_epoch(self):
"""Verify due.epoch formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.epoch")
self.assertRegexpMatches(out, r'1\s+\d{10}')
self.assertRegexpMatches(out, r'2\s+\d{10}')
def test_date_format_iso(self):
"""Verify due.iso formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.iso")
self.assertRegexpMatches(out, r'1\s+\d{8}T\d{6}Z')
self.assertRegexpMatches(out, r'2\s+\d{8}T\d{6}Z')
def test_date_format_age(self):
"""Verify due.age formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.age")
self.assertRegexpMatches(out, r'1\s+[0-9.]+d')
self.assertRegexpMatches(out, r'2\s+-[0-9.]+[hmin]+')
def test_date_format_remaining(self):
"""Verify due.remaining formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.remaining")
self.assertRegexpMatches(out, r'1')
self.assertRegexpMatches(out, r'2\s+\d+\S+')
def test_date_format_relative(self):
"""Verify due.relative formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.relative")
self.assertRegexpMatches(out, r'1\s+-[0-9.]+d')
self.assertRegexpMatches(out, r'2\s+[0-9.]+[hmin]+')
def test_date_format_countdown(self):
"""Verify due.countdown formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.countdown")
self.assertRegexpMatches(out, r'1\s+\d+\S+')
self.assertRegexpMatches(out, r'2\s+')
def test_date_format_unrecognized(self):
"""Verify due.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,due.donkey,description")
self.assertEqual(err, "Unrecognized column format 'due.donkey'\n")
class TestCustomColumns(TestCase):
def setUp(self):
"""Executed before each test in the class"""
self.t = Task()
def test_unrecognized_column(self):
"""verify that using a bogus colum generates an error"""
self.t.config("report.foo.description", "DESC")
self.t.config("report.foo.columns", "id,foo,description")
self.t.config("report.foo.sort", "id+")
self.t.config("report.foo.filter", "project:A")
# Generate the usage screen, and locate the custom report on it.
code, out, err = self.t.runError("foo")
self.assertIn("Unrecognized column name 'foo'.", err)
class TestUDAFormats(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("report.xxx.columns", "id,priority")
cls.t.config("verbose", "nothing")
cls.t.config("uda.priority.indicator", "P")
cls.t("add one priority:H")
def test_uda_format_formatted(self):
"""Verify priority.default formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,priority.default")
self.assertRegexpMatches(out, r'1\s+H')
def test_uda_format_indicator(self):
"""Verify priority.indicator formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,priority.indicator")
self.assertRegexpMatches(out, r'1\s+P')
def test_uda_format_unrecognized(self):
"""Verify priority.donkey formatting fails"""
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,priority.donkey")
self.assertEqual(err, "Unrecognized column format 'priority.donkey'\n")
"""
depends list* 1 2 10
count [3]
indicator D
start active* ✓
"""
class TestFeature1061(TestCase):
def setUp(self):
"""Executed before each test in the class"""
self.t = Task()
def test_columns(self):
"""1061: Verify 'task columns' works"""
code, out, err = self.t("columns")
self.assertIn("description", out)
self.assertIn("uuid", out)
self.assertIn("project", out)
def test_columns_color(self):
"""1061: Verify 'task columns rc._forcecolor:1' works"""
code, out, err = self.t("columns rc._forcecolor:1")
self.assertIn("description", out)
self.assertIn("uuid", out)
self.assertIn("project", out)
def test_columns_specific(self):
"""1061: Verify 'task columns escr' works"""
code, out, err = self.t("columns escr")
self.assertIn("description", out)
self.assertNotIn("uuid", out)
self.assertNotIn("project", out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4 ft=python
|