mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Test: Convert roundtrip.t to Python and merge with import.t
This commit is contained in:
parent
ddfb9af407
commit
bc64a08054
2 changed files with 41 additions and 88 deletions
|
@ -146,14 +146,53 @@ class TestImport(TestCase):
|
|||
def test_import_newlines_whitespace(self):
|
||||
"""JSON array with whitespace before and after names and values"""
|
||||
_data = """[
|
||||
{ "uuid":"00000000-0000-0000-0000-000000000000" , "description" : "zero" ,"project":"A", "status":"pending","entry":"1234567889" } ,
|
||||
{ "uuid":"11111111-1111-1111-1111-111111111111","description":"one","project":"B","status":"pending","entry":"1234567889"}, {"uuid":"22222222-2222-2222-2222-222222222222","description":"two","status":"completed","entry":"1234524689","end":"1234524690" }
|
||||
{ "uuid":"a0000000-a000-a000-a000-a00000000000" , "description" : "zero" ,"project":"A", "status":"pending","entry":"1234567889" } ,
|
||||
{ "uuid":"a1111111-a111-a111-a111-a11111111111","description":"one","project":"B","status":"pending","entry":"1234567889"}, {"uuid":"a2222222-a222-a222-a222-a22222222222","description":"two","status":"completed","entry":"1234524689","end":"1234524690" }
|
||||
]"""
|
||||
code, out, err = self.t("import", input=_data)
|
||||
self.assertIn("Imported 3 tasks", err)
|
||||
self.assertData1()
|
||||
|
||||
|
||||
class TestImportExportRoundtrip(TestCase):
|
||||
def setUp(self):
|
||||
self.t1 = Task()
|
||||
self.t2 = Task()
|
||||
|
||||
for client in (self.t1, self.t2):
|
||||
client.config("dateformat", "m/d/Y")
|
||||
client.config("verbose", "off")
|
||||
client.config("defaultwidth", "100")
|
||||
client.config("json.array", "off")
|
||||
|
||||
def _validate_data(self, client):
|
||||
code, out, err = client("_get 1.priority")
|
||||
self.assertEqual("H\n", out)
|
||||
code, out, err = client("_get 1.project")
|
||||
self.assertEqual("A\n", out)
|
||||
code, out, err = client("_get 1.description")
|
||||
self.assertEqual("one/1\n", out)
|
||||
code, out, err = client("_get 2.tags")
|
||||
self.assertEqual("tag1,tag2\n", out)
|
||||
code, out, err = client("_get 2.description")
|
||||
self.assertEqual("two\n", out)
|
||||
|
||||
def test_import_export(self):
|
||||
"""Test importing exported data"""
|
||||
self.t1("add priority:H project:A -- one/1")
|
||||
self.t1("add +tag1 +tag2 two")
|
||||
|
||||
code, out1, err = self.t1("export")
|
||||
|
||||
self.t2("import -", input=out1)
|
||||
code, out2, err = self.t2("export")
|
||||
|
||||
self.assertEqual(out1, out2)
|
||||
|
||||
self._validate_data(self.t1)
|
||||
self._validate_data(self.t2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue