From 59cbce5c9815f64230ce0206b7e883077381c390 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Thu, 16 Mar 2017 13:06:51 +0100 Subject: [PATCH] adding tests to compare with folder --- tests/test_compare.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/test_compare.py b/tests/test_compare.py index f7155a4..7120893 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -70,13 +70,22 @@ class TestCompare(unittest.TestCase): # create the dotfiles to test d1, c1 = create_random_file(fold_config) + self.assertTrue(os.path.exists(d1)) self.addCleanup(clean, d1) d2, c2 = create_random_file(fold_subcfg) + self.assertTrue(os.path.exists(d2)) self.addCleanup(clean, d2) d3, c3 = create_random_file(fold_tmp) + self.assertTrue(os.path.exists(d3)) self.addCleanup(clean, d3) d4, c4 = create_random_file(fold_tmp, binary=True) + self.assertTrue(os.path.exists(d4)) self.addCleanup(clean, d4) + d5 = get_tempfolder() + self.assertTrue(os.path.exists(d5)) + self.addCleanup(clean, d5) + d6, _ = create_random_file(d5) + self.assertTrue(os.path.exists(d6)) # create the config file profile = get_string(5) @@ -87,33 +96,40 @@ class TestCompare(unittest.TestCase): create=self.CONFIG_CREATE) self.assertTrue(os.path.exists(confpath)) conf, opts = load_config(confpath, self.CONFIG_DOTPATH, profile) - dfiles = [d1, d2, d3, d4] + dfiles = [d1, d2, d3, d4, d5] # import the files importer(opts, conf, dfiles) conf, opts = load_config(confpath, self.CONFIG_DOTPATH, profile) # compare the files - expected = {d1: True, d2: True, d3: True, d4: True} + expected = {d1: True, d2: True, d3: True, d4: True, d5: True} results = self.compare(opts, conf, tmp, len(dfiles)) self.assertTrue(results == expected) # modify file self.edit_content(d1, get_string(20)) - expected = {d1: False, d2: True, d3: True, d4: True} + expected = {d1: False, d2: True, d3: True, d4: True, d5: True} results = self.compare(opts, conf, tmp, len(dfiles)) self.assertTrue(results == expected) # modify binary file self.edit_content(d4, bytes(get_string(20), 'ascii'), binary=True) - expected = {d1: False, d2: True, d3: True, d4: False} + expected = {d1: False, d2: True, d3: True, d4: False, d5: True} + results = self.compare(opts, conf, tmp, len(dfiles)) + self.assertTrue(results == expected) + + # add file in folder + d7, _ = create_random_file(d5) + self.assertTrue(os.path.exists(d7)) + expected = {d1: False, d2: True, d3: True, d4: False, d5: False} results = self.compare(opts, conf, tmp, len(dfiles)) self.assertTrue(results == expected) # modify all files self.edit_content(d2, get_string(20)) self.edit_content(d3, get_string(21)) - expected = {d1: False, d2: False, d3: False, d4: False} + expected = {d1: False, d2: False, d3: False, d4: False, d5: False} results = self.compare(opts, conf, tmp, len(dfiles)) self.assertTrue(results == expected)