From 888655413da06dad9e09cb35f3d441da9252d5a3 Mon Sep 17 00:00:00 2001 From: Peter Kessen Date: Sun, 20 Sep 2015 12:54:46 +0200 Subject: [PATCH 1/3] added testcase for fields command first check of function without check of consistent output --- test/test_ui_commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_ui_commands.py b/test/test_ui_commands.py index 08f44eb57..60e06a1e1 100644 --- a/test/test_ui_commands.py +++ b/test/test_ui_commands.py @@ -84,6 +84,25 @@ class QueryTest(_common.TestCase): self.check_do_query(0, 2, album=True, also_items=False) +class FieldsTest(_common.TestCase): + def setUp(self): + super(FieldsTest, self).setUp() + + self.io.install() + + self.libdir = os.path.join(self.temp_dir, 'testlibdir') + os.mkdir(self.libdir) + + # Add a file to the library but don't copy it in yet. + self.lib = library.Library(':memory:', self.libdir) + + def tearDown(self): + self.io.restore() + + def test_fields_func(self): + commands.fields_func(self.lib, [], []) + + def suite(): return unittest.TestLoader().loadTestsFromName(__name__) From 8fc292bc44fa099e22fc870a2b6b08471ec727e6 Mon Sep 17 00:00:00 2001 From: Peter Kessen Date: Fri, 25 Sep 2015 16:37:39 +0200 Subject: [PATCH 2/3] Using LibTestCase instead of TestCase --- test/test_ui_commands.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/test_ui_commands.py b/test/test_ui_commands.py index 60e06a1e1..2b3f2423f 100644 --- a/test/test_ui_commands.py +++ b/test/test_ui_commands.py @@ -84,18 +84,12 @@ class QueryTest(_common.TestCase): self.check_do_query(0, 2, album=True, also_items=False) -class FieldsTest(_common.TestCase): +class FieldsTest(_common.LibTestCase): def setUp(self): super(FieldsTest, self).setUp() self.io.install() - self.libdir = os.path.join(self.temp_dir, 'testlibdir') - os.mkdir(self.libdir) - - # Add a file to the library but don't copy it in yet. - self.lib = library.Library(':memory:', self.libdir) - def tearDown(self): self.io.restore() From 59a1f8be018804c6ade6c395411304a8e33f5dc2 Mon Sep 17 00:00:00 2001 From: Peter Kessen Date: Fri, 25 Sep 2015 17:15:50 +0200 Subject: [PATCH 3/3] extended test_fields_func to check output --- test/test_ui_commands.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_ui_commands.py b/test/test_ui_commands.py index 2b3f2423f..dd8eb47a3 100644 --- a/test/test_ui_commands.py +++ b/test/test_ui_commands.py @@ -93,8 +93,24 @@ class FieldsTest(_common.LibTestCase): def tearDown(self): self.io.restore() + def remove_keys(self, l, text): + for i in text: + try: + l.remove(i) + except ValueError: + pass + def test_fields_func(self): commands.fields_func(self.lib, [], []) + items = library.Item.all_keys() + albums = library.Album.all_keys() + + output = self.io.stdout.get().split() + self.remove_keys(items, output) + self.remove_keys(albums, output) + + self.assertEqual(len(items), 0) + self.assertEqual(len(albums), 0) def suite():