mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TW-158: Add failing tests
This commit is contained in:
parent
6f3957d858
commit
0f4cbc5dc9
2 changed files with 50 additions and 3 deletions
|
@ -146,10 +146,22 @@ class TestExportCommand(TestCase):
|
||||||
self.t(('add', 'wrong, everything depends on me task'))
|
self.t(('add', 'wrong, everything depends on me task'))
|
||||||
self.t('1 modify depends:2,3')
|
self.t('1 modify depends:2,3')
|
||||||
|
|
||||||
values = self.export(1)['depends']
|
deps = self.export(1)['depends']
|
||||||
self.assertString(values)
|
self.assertType(deps, list)
|
||||||
|
|
||||||
for uuid in values.split(','):
|
for uuid in deps:
|
||||||
|
self.assertString(uuid, UUID_REGEXP, regexp=True)
|
||||||
|
|
||||||
|
def test_export_depends_oldformat(self):
|
||||||
|
self.t(('add', 'everything depends on me task'))
|
||||||
|
self.t(('add', 'wrong, everything depends on me task'))
|
||||||
|
self.t('1 modify depends:2,3')
|
||||||
|
|
||||||
|
code, out, err = self.t("rc.json.array=off rc.json.depends.array=off 1 export")
|
||||||
|
deps = json.loads(out)["depends"]
|
||||||
|
self.assertString(deps)
|
||||||
|
|
||||||
|
for uuid in deps.split(','):
|
||||||
self.assertString(uuid, UUID_REGEXP, regexp=True)
|
self.assertString(uuid, UUID_REGEXP, regexp=True)
|
||||||
|
|
||||||
def test_export_urgency(self):
|
def test_export_urgency(self):
|
||||||
|
|
|
@ -151,6 +151,41 @@ class TestImport(TestCase):
|
||||||
self.assertIn("Imported 3 tasks", err)
|
self.assertIn("Imported 3 tasks", err)
|
||||||
self.assertData1()
|
self.assertData1()
|
||||||
|
|
||||||
|
def test_import_old_depend(self):
|
||||||
|
"""One dependency used to be a plain string"""
|
||||||
|
_data = """{"uuid":"a0000000-a000-a000-a000-a00000000000","depends":"a1111111-a111-a111-a111-a11111111111","description":"zero","project":"A","status":"pending","entry":"1234567889"}"""
|
||||||
|
self.t("import", input=self.data1)
|
||||||
|
self.t("import", input=_data)
|
||||||
|
_t = self.t.export("a0000000-a000-a000-a000-a00000000000")[0]
|
||||||
|
self.assertEqual(_t["depends"], "a1111111-a111-a111-a111-a11111111111")
|
||||||
|
|
||||||
|
def test_import_old_depends(self):
|
||||||
|
"""Several dependencies used to be a comma seperated string"""
|
||||||
|
_data = """{"uuid":"a0000000-a000-a000-a000-a00000000000","depends":"a1111111-a111-a111-a111-a11111111111,a2222222-a222-a222-a222-a22222222222","description":"zero","project":"A","status":"pending","entry":"1234567889"}"""
|
||||||
|
self.t("import", input=self.data1)
|
||||||
|
self.t("import", input=_data)
|
||||||
|
_t = self.t.export("a0000000-a000-a000-a000-a00000000000")[0]
|
||||||
|
self.assertIn("a1111111-a111-a111-a111-a11111111111", _t["depends"])
|
||||||
|
self.assertIn("a2222222-a222-a222-a222-a22222222222", _t["depends"])
|
||||||
|
|
||||||
|
def test_import_new_depend(self):
|
||||||
|
"""One dependency is a single array element"""
|
||||||
|
_data = """{"uuid":"a0000000-a000-a000-a000-a00000000000","depends":["a1111111-a111-a111-a111-a11111111111"],"description":"zero","project":"A","status":"pending","entry":"1234567889"}"""
|
||||||
|
self.t("import", input=self.data1)
|
||||||
|
self.t("import", input=_data)
|
||||||
|
_t = self.t.export("a0000000-a000-a000-a000-a00000000000")[0]
|
||||||
|
self.assertEqual(_t["depends"][0], "a1111111-a111-a111-a111-a11111111111")
|
||||||
|
|
||||||
|
def test_import_new_depends(self):
|
||||||
|
"""Several dependencies are an array"""
|
||||||
|
_data = """{"uuid":"a0000000-a000-a000-a000-a00000000000","depends":["a1111111-a111-a111-a111-a11111111111","a2222222-a222-a222-a222-a22222222222"],"description":"zero","project":"A","status":"pending","entry":"1234567889"}"""
|
||||||
|
self.t("import", input=self.data1)
|
||||||
|
self.t("import", input=_data)
|
||||||
|
_t = self.t.export("a0000000-a000-a000-a000-a00000000000")[0]
|
||||||
|
|
||||||
|
for _uuid in ["a1111111-a111-a111-a111-a11111111111","a2222222-a222-a222-a222-a22222222222"]:
|
||||||
|
self.assertTrue((_t["depends"][0] == _uuid) or (_t["depends"][1] == _uuid))
|
||||||
|
|
||||||
|
|
||||||
class TestImportExportRoundtrip(TestCase):
|
class TestImportExportRoundtrip(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue