mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Add uuid UDA type (#3827)
Mainly so that UDAs that refer to another task can be formated as "short".
This commit is contained in:
parent
bae37d9448
commit
31829d61fc
6 changed files with 107 additions and 12 deletions
|
@ -109,29 +109,26 @@ class TestUUIDFormats(TestCase):
|
|||
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("report.xxx.columns", "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)
|
||||
code, out, err = self.t("xxx rc.report.xxx.columns:uuid.long")
|
||||
self.assertEqual(self.uuid, out.strip())
|
||||
|
||||
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)
|
||||
code, out, err = self.t("xxx rc.report.xxx.columns:uuid.short")
|
||||
self.assertEqual(self.uuid[:8], out.strip())
|
||||
|
||||
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")
|
||||
code, out, err = self.t.runError("xxx rc.report.xxx.columns:uuid.donkey")
|
||||
self.assertEqual(err, "Unrecognized column format 'uuid.donkey'\n")
|
||||
|
||||
|
||||
|
@ -482,6 +479,70 @@ start active* ✓
|
|||
"""
|
||||
|
||||
|
||||
class TestUDAUUIDFormats(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Executed once before any test in the class"""
|
||||
cls.t = Task()
|
||||
cls.t.config("verbose", "nothing")
|
||||
cls.t.config("uda.uda_uuid.label", "uda_uuid")
|
||||
cls.t.config("uda.uda_uuid.type", "uuid")
|
||||
cls.t.config("report.xxx.columns", "uda_uuid")
|
||||
|
||||
cls.t("add zero")
|
||||
code, out, err = cls.t("_get 1.uuid")
|
||||
cls.t("add uda_uuid:{} one".format(out.strip()))
|
||||
code, out, err = cls.t("_get 2.uda_uuid")
|
||||
cls.uda_uuid = out.strip()
|
||||
|
||||
def test_uda_uuid_invalid_fails(self):
|
||||
"""Verify adding invalid uuid fails"""
|
||||
code, out, err = self.t.runError("add uda_uuid:shrek three")
|
||||
self.assertNotEqual(code, 0)
|
||||
self.assertIn("uda_uuid", err.strip())
|
||||
self.assertIn("shrek", err.strip())
|
||||
|
||||
def test_uda_uuid_long(self):
|
||||
"""Verify formatting of 'uda_uuid.long' column"""
|
||||
code, out, err = self.t("2 xxx rc.report.xxx.columns:uda_uuid.long")
|
||||
self.assertEqual(self.uda_uuid, out.strip())
|
||||
|
||||
def test_uda_uuid_short(self):
|
||||
"""Verify formatting of 'uda_uuid.short' column"""
|
||||
code, out, err = self.t("2 xxx rc.report.xxx.columns:uda_uuid.short")
|
||||
self.assertEqual(self.uda_uuid[:8], out.strip())
|
||||
|
||||
def test_uda_uuid_format_unrecognized(self):
|
||||
"""Verify uda_uuid.donkey formatting fails"""
|
||||
code, out, err = self.t.runError("xxx rc.report.xxx.columns:id,uda_uuid.donkey")
|
||||
self.assertEqual(err, "Unrecognized column format 'uda_uuid.donkey'\n")
|
||||
|
||||
|
||||
class TestUDAUUIDReconfiguredFromString(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Executed once before any test in the class"""
|
||||
cls.t = Task()
|
||||
cls.t.config("verbose", "nothing")
|
||||
cls.t.config("uda.uda_uuid.label", "uda_uuid")
|
||||
cls.t.config("report.xxx.columns", "uda_uuid")
|
||||
|
||||
cls.t.config("uda.uda_uuid.type", "string")
|
||||
cls.expected_str = 3 * "littlepigs"
|
||||
cls.t("add uda_uuid:{} one".format(cls.expected_str))
|
||||
cls.t.config("uda.uda_uuid.type", "uuid")
|
||||
|
||||
def test_uda_uuid_long(self):
|
||||
"""Verify formatting of 'uda_uuid.long' column"""
|
||||
code, out, err = self.t("1 xxx rc.report.xxx.columns:uda_uuid.long")
|
||||
self.assertEqual(self.expected_str, out.strip())
|
||||
|
||||
def test_uda_uuid_short(self):
|
||||
"""Verify formatting of 'uda_uuid.short' column"""
|
||||
code, out, err = self.t("1 xxx rc.report.xxx.columns:uda_uuid.short")
|
||||
self.assertEqual(self.expected_str[:8], out.strip())
|
||||
|
||||
|
||||
class TestFeature1061(TestCase):
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue